Skip to content

Add more robust support for --nofix #216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 6, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/libfuturize/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,27 @@ def main(args=None):
print("Use --help to show usage.", file=sys.stderr)
return 2

unwanted_fixes = set(fixer_pkg + ".fix_" + fix for fix in options.nofix)
unwanted_fixes = set()
for fix in options.nofix:
if ".fix_" in fix:
unwanted_fixes.add(fix)
else:
# Infer the full module name for the fixer.
# First ensure that no names clash (e.g.
# lib2to3.fixes.fix_blah and libfuturize.fixes.fix_blah):
found = [f for f in avail_fixes
if f.endswith('fix_{0}'.format(fix))]
if len(found) > 1:
print("Ambiguous fixer name. Choose a fully qualified "
"module name instead from these:\n" +
"\n".join(" " + myf for myf in found),
file=sys.stderr)
return 2
elif len(found) == 0:
print("Unknown fixer. Use --list-fixes or -l for a list.",
file=sys.stderr)
return 2
unwanted_fixes.add(found[0])

extra_fixes = set()
if options.all_imports:
Expand Down