@@ -491,8 +491,6 @@ def _fix_file(filename: str, args: argparse.Namespace) -> int:
491
491
if args .diff_only :
492
492
_report_diff (contents , new_contents , filename )
493
493
elif args .print_only :
494
- print ('!!! --print-only is deprecated' , file = sys .stderr )
495
- print ('!!! maybe use `-` instead?' , file = sys .stderr )
496
494
print (f'==> { filename } <==' , file = sys .stderr )
497
495
print (new_contents , end = '' )
498
496
else :
@@ -806,7 +804,7 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
806
804
group = parser .add_mutually_exclusive_group (required = False )
807
805
group .add_argument (
808
806
'--diff-only' , action = 'store_true' ,
809
- help = 'Show unified diff instead of applying reordering.' ,
807
+ help = '(Deprecated) Show unified diff instead of applying reordering.' ,
810
808
)
811
809
group .add_argument (
812
810
'--print-only' , action = 'store_true' ,
@@ -860,23 +858,36 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
860
858
parser .add_argument (
861
859
'--separate-relative' , action = 'store_true' ,
862
860
help = (
863
- 'Separate explicit relative (`from . import ...`) imports into a '
864
- 'separate block.'
861
+ '(Deprecated) Separate explicit relative (`from . import ...`) '
862
+ 'imports into a separate block.'
865
863
),
866
864
)
867
865
868
866
parser .add_argument (
869
867
'--separate-from-import' , action = 'store_true' ,
870
868
help = (
871
- 'Separate `from xx import xx` imports from `import xx` imports '
872
- ' with a new line.'
869
+ '(Deprecated) Separate `from xx import xx` imports from '
870
+ '`import xx` imports with a new line.'
873
871
),
874
872
)
875
873
876
874
_add_version_options (parser )
877
875
878
876
args = parser .parse_args (argv )
879
877
878
+ for option in (
879
+ 'diff_only' ,
880
+ 'print_only' ,
881
+ 'separate_relative' ,
882
+ 'separate_from_import' ,
883
+ ):
884
+ if getattr (args , option ):
885
+ print (
886
+ f'warning: --{ option .replace ("_" , "-" )} is deprecated '
887
+ f'and will be removed' ,
888
+ file = sys .stderr ,
889
+ )
890
+
880
891
for k , v in REMOVALS .items ():
881
892
if args .min_version >= k :
882
893
args .remove_import .extend (v )
0 commit comments