@@ -255,18 +255,22 @@ class Reformatter:
255255 .. autosummary-widths:: 5/16
256256 """
257257
258- #: The filename being reformatted.
258+ #: The filename being reformatted, as a POSIX-style path .
259259 filename : str
260260
261- #: The filename being reformatted, as a POSIX-style path .
261+ #: The filename being reformatted, as a :class:`~.PathPlus` object .
262262 file_to_format : PathPlus
263263
264+ #: The file extension of the file being reformatted.
265+ filetype : str
266+
264267 #: The ``formate`` configuration, parsed from a TOML file (or similar).
265268 config : FormateConfigDict
266269
267270 def __init__ (self , filename : PathLike , config : FormateConfigDict ):
268271 self .file_to_format = PathPlus (filename )
269272 self .filename = self .file_to_format .as_posix ()
273+ self .filetype = self .file_to_format .suffix
270274 self .config = config
271275 self ._unformatted_source = self .file_to_format .read_text ()
272276 self ._reformatted_source : Optional [str ] = None
@@ -279,7 +283,7 @@ def run(self) -> bool:
279283 """
280284
281285 hooks = parse_hooks (self .config )
282- hooks = get_hooks_for_filetype (self .file_to_format . suffix , hooks )
286+ hooks = get_hooks_for_filetype (self .filetype , hooks )
283287 reformatted_source = StringList (call_hooks (hooks , self ._unformatted_source , self .filename ))
284288 reformatted_source .blankline (ensure_single = True )
285289
0 commit comments