techalchemy commented on a change in pull request #4685: [AIRFLOW-3862] Check
types with mypy.
URL: https://github.com/apache/airflow/pull/4685#discussion_r261841253
##########
File path: setup.py
##########
@@ -319,6 +318,7 @@ def do_setup():
'sqlalchemy>=1.1.15, <1.3.0',
'tabulate>=0.7.5, <=0.8.2',
'tenacity==4.12.0',
+ 'typing',
Review comment:
The point of the function-based approach with the safety net of handling the
`ImportError` is to provide some flexibility if it's desired -- typechecking is
_very_ slow, and by always performing the requisite imports, you basically
ensure that annotations are going to be evaluated at runtime no matter what.
This approach allows you a few options:
1. You can set this up as a configuration parameter and toggle it
2. You can make typing an extra that has a builtin failsafe if it's not
installed
3. Even if you do only what I pasted above, you ensure that annotations
won't be evaluated at runtime if you put all of your typing imports inside an
`if MYPY_RUNNING:` block.
The imports themselves aren't slow, it's the consequence of performing them
that causes a performance hit.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services