File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,16 +51,25 @@ def fix_code(code, directory):
5151 line_length = black_config ["line-length" ]
5252 if "skip-string-normalization" in black_config :
5353 string_normalization = not black_config ["skip-string-normalization" ]
54+ if "target-version" in black_config :
55+ target_versions = {
56+ black .TargetVersion [v .upper ()] for v in black_config ["target-version" ]
57+ }
58+
5459 try :
5560 if parse_version (black .__version__ ) < parse_version ("19.0" ):
5661 reformatted_source = black .format_file_contents (
57- src_contents = code , line_length = line_length , fast = False )
62+ src_contents = code , line_length = line_length , fast = False
63+ )
5864 else :
5965 fm = black .FileMode (
6066 line_length = line_length ,
61- string_normalization = string_normalization )
67+ string_normalization = string_normalization ,
68+ target_versions = target_versions ,
69+ )
6270 reformatted_source = black .format_file_contents (
63- src_contents = code , fast = False , mode = fm )
71+ src_contents = code , fast = False , mode = fm
72+ )
6473 return reformatted_source
6574 except black .NothingChanged :
6675 return code
You can’t perform that action at this time.
0 commit comments