-
Notifications
You must be signed in to change notification settings - Fork 14.8k
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
[AIRFLOW-4227] Use python3-style type annotations. #5030
Conversation
de12238
to
00b663b
Compare
run_unit_tests.sh
Outdated
@@ -34,9 +34,9 @@ nose_args=$@ | |||
# Generate the `airflow` executable if needed | |||
which airflow > /dev/null || python setup.py develop | |||
|
|||
echo "Initializing the DB" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accident?
Note: there is also this issue https://issues.apache.org/jira/browse/AIRFLOW-4205, part of a collection of issues on removing Python 2. |
00b663b
to
26fbbd1
Compare
Thanks @BasPH. Also, will we support python3.5 in the future? If so, we can use function annotations but not variable annotations. |
We should probably support Python 3.5.2 which is what Ubuntu ships |
3741b1c
to
59f0a90
Compare
Thanks @ashb, I backed out variable annotations, and tests are passing on 3.5.x. |
59f0a90
to
532c6fa
Compare
What do you think about replacing |
532c6fa
to
2344d4c
Compare
Added some typed namedtuples. Since we're supporting python3.5, we can't use variable annotations, so I used the backwards-compatible syntax. |
Can you rebase onto master? |
a0fa71a
to
942d40c
Compare
Looks like #5090 will fix the kubernetes tests here once it's ready. |
942d40c
to
8471971
Compare
Codecov Report
@@ Coverage Diff @@
## master #5030 +/- ##
==========================================
+ Coverage 78.67% 78.68% +<.01%
==========================================
Files 470 470
Lines 30013 30020 +7
==========================================
+ Hits 23613 23620 +7
Misses 6400 6400
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good @jmcarp
One more comment, apart from that LGTM. Makes the code much more readable.
@@ -99,7 +99,7 @@ class AirflowTestPlugin(AirflowPlugin): | |||
flask_blueprints = [bp] | |||
appbuilder_views = [v_appbuilder_package] | |||
appbuilder_menu_items = [appbuilder_mitem] | |||
stat_name_handler = staticmethod(stat_name_dummy_handler) | |||
stat_name_handler = stat_name_dummy_handler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change seems unrelated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be because mypy was complaining about this otherwise?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right @ashb, and mypy might be right to complain about staticmethod
here, since stat_name_dummy_handler
is a function and not a method, and already has the expected signature.
We could revisit this pr given we drop PY2? |
2ccd6aa
to
d34804e
Compare
02:01 $ grep -RE 'namedtuple\(' . --include \*.py
./tests/models/test_connection.py:ConnectionParts = namedtuple("ConnectionParts", ["conn_type", "login", "password", "host", "port", "schema"])
./tests/contrib/hooks/test_azure_container_instance_hook.py: named_instance = namedtuple("InstanceView", instance_view.keys())(*instance_view.values())
./tests/contrib/hooks/test_azure_container_instance_hook.py: named_instance = namedtuple("Events", instance_view.keys())(*instance_view.values())
./tests/contrib/hooks/test_wasb_hook.py: Blob = namedtuple('Blob', ['name']) It seems to me that all classes have not been changed. WDYT? |
d34804e
to
dc0de57
Compare
736b616
to
7491815
Compare
7491815
to
192f3f9
Compare
@mik-laj: I hadn't changed all the named tuples in tests, but now I've gone through and dropped all uses of |
Make sure you have checked all steps below.
Jira
Description
Tests
Commits
Documentation
Code Quality
flake8