@@ -77,7 +77,7 @@ def run(self) -> List[nodes.Node]:
7777 return [self .create_card (self , self .arguments , self .options )]
7878
7979 @classmethod
80- def create_card (
80+ def create_card ( # noqa: PLR0912, PLR0915
8181 cls , inst : SphinxDirective , arguments : Optional [list ], options : dict
8282 ) -> nodes .Node :
8383 """Run the directive."""
@@ -118,7 +118,7 @@ def create_card(
118118 "" ,
119119 uri = options ["img-top" ],
120120 alt = img_alt ,
121- classes = ["sd-card-img-top" ] + options .get ("class-img-top" , []),
121+ classes = ["sd-card-img-top" , * options .get ("class-img-top" , [])] ,
122122 )
123123 container .append (image_top )
124124
@@ -137,8 +137,11 @@ def create_card(
137137 if arguments :
138138 title = create_component (
139139 "card-title" ,
140- ["sd-card-title" , "sd-font-weight-bold" ]
141- + options .get ("class-title" , []),
140+ [
141+ "sd-card-title" ,
142+ "sd-font-weight-bold" ,
143+ * options .get ("class-title" , []),
144+ ],
142145 )
143146 textnodes , _ = inst .state .inline_text (arguments [0 ], inst .lineno )
144147 title_container = PassthroughTextElement ()
@@ -160,7 +163,7 @@ def create_card(
160163 "" ,
161164 uri = options ["img-bottom" ],
162165 alt = img_alt ,
163- classes = ["sd-card-img-bottom" ] + options .get ("class-img-bottom" , []),
166+ classes = ["sd-card-img-bottom" , * options .get ("class-img-bottom" , [])] ,
164167 )
165168 container .append (image_bottom )
166169
@@ -225,7 +228,7 @@ def split_content(content: StringList, offset: int) -> CardContent:
225228 return CardContent (body , header , footer )
226229
227230 @classmethod
228- def _create_component (
231+ def _create_component ( # noqa: PLR0913
229232 cls ,
230233 inst : SphinxDirective ,
231234 name : str ,
@@ -235,7 +238,7 @@ def _create_component(
235238 ) -> nodes .container :
236239 """Create the header, body, or footer."""
237240 component = create_component (
238- f"card-{ name } " , [f"sd-card-{ name } " ] + options .get (f"class-{ name } " , [])
241+ f"card-{ name } " , [f"sd-card-{ name } " , * options .get (f"class-{ name } " , [])]
239242 )
240243 inst .set_source_info (component ) # TODO set proper lines
241244 inst .state .nested_parse (content , offset , component )
@@ -246,9 +249,7 @@ def _create_component(
246249 def add_card_child_classes (node ):
247250 """Add classes to specific child nodes."""
248251 for para in findall (node )(nodes .paragraph ):
249- para ["classes" ] = ([] if "classes" not in para else para ["classes" ]) + [
250- "sd-card-text"
251- ]
252+ para ["classes" ] = [* para .get ("classes" , []), "sd-card-text" ]
252253 # for title in findall(node)(nodes.title):
253254 # title["classes"] = ([] if "classes" not in title else title["classes"]) + [
254255 # "sd-card-title"
@@ -273,11 +274,15 @@ def run(self) -> List[nodes.Node]:
273274 self .arguments [0 ].strip ()
274275 )
275276 except ValueError as exc :
276- raise self .error (f"Invalid directive argument: { exc } " )
277+ raise self .error (f"Invalid directive argument: { exc } " ) from exc
277278 container = create_component (
278279 "card-carousel" ,
279- ["sd-sphinx-override" , "sd-cards-carousel" , f"sd-card-cols-{ cols } " ]
280- + self .options .get ("class" , []),
280+ [
281+ "sd-sphinx-override" ,
282+ "sd-cards-carousel" ,
283+ f"sd-card-cols-{ cols } " ,
284+ * self .options .get ("class" , []),
285+ ],
281286 )
282287 self .set_source_info (container )
283288 self .state .nested_parse (self .content , self .content_offset , container )
0 commit comments