Skip to content
Myr

Add skip to fix unnoticed bug with good imports

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fixes logic so that imports that should not be changed are skipped, which was not happening correctly before.

authored by Keyan Pishdadian · committed by Keyan Pishdadian · parent 818c42c · Browse files · 2 files+9 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+9 added−1 removed

  • other:+9 added−1 removed

2 files+9 added−1 removed

modified:scripts/flaskext_migrate.py+2 added
38 unmodified lines
39 """40 from_imports = red.find_all("FromImport")41 for x, node in enumerate(from_imports):42 values = node.value43 if len(values) < 2:44 continue45 if (values[0].value == 'flask') and (values[1].value == 'ext'):46 # Case 147 if len(node.value) == 3:48 package = values[2].value
114 unmodified lines
modified:scripts/test_import_migration.py+7 added-1 removed
43 unmodified lines
44 output = migrate.fix_tester(red)45 assert output == "import flask_foo as foobar"464748def test__named_from_import():48def test_named_from_import():49 red = RedBaron("from flask.ext.foo import bar as baz")50 output = migrate.fix_tester(red)51 assert output == "from flask_foo import bar as baz"52
15 unmodified lines
68 "flask.ext.foo.bar(var)")69 output = migrate.fix_tester(red)70 assert output == ("import flask_foo\n\n"71 "flask_foo.bar(var)")727374def test_no_change_to_import():75 red = RedBaron("from flask import Flask")76 output = migrate.fix_tester(red)77 assert output == "from flask import Flask"