-
Notifications
You must be signed in to change notification settings - Fork 26
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
Add compat module for typing airflow.utils.context.Context
#619
Conversation
Codecov Report
@@ Coverage Diff @@
## main #619 +/- ##
=======================================
Coverage 98.30% 98.30%
=======================================
Files 78 79 +1
Lines 4127 4133 +6
=======================================
+ Hits 4057 4063 +6
Misses 70 70
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
ca8f84d
to
b08811a
Compare
airflow.utils.context.Context
import under TYPE_CHECKING
airflow.utils.context.Context
from airflow.utils.context import Context | ||
except ModuleNotFoundError: | ||
|
||
class Context(MutableMapping[str, Any]): # type: ignore[no-redef] |
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.
With the approach of Context = MutableMapping[str, Any]
, mypy was complaining about not being able to assign to a type and the variable assignment types not matching. Instead of ignoring those mypy errors (which felt icky), I decided to redefine the typing class and ignore the redefinition mypy error.
Does this seem reasonable? Any other mypy workarounds?
The pre-commit.ci check is failing for |
Of course, if there is a preference of having unit test over a pre-commit hook, I can change that no problem! |
@josh-fell Still code coverage is failing |
The `airflow.utils.context` module was not introduced to OSS Airflow until 2.2.3. Importing this module as a top-level import sets an implicit, minimum requirement for Airflow 2.2.3 which is higher than the minumum `apache-airflow` requirement set for Astronomer Providers. This PR adds a typing compat module to be used throughout the repo for consistent typing of `context`.
Ah yes. Thanks for the poke. Just pushed a unit test in e2a9ade which hopefully helps. |
Good to know the pre-commit hook works. Updated the dbt Cloud modules. |
The
airflow.utils.context
module was not introduced to OSS Airflow until 2.2.3. Importing this module as a top-level import sets an implicit, minimum requirement for Airflow 2.2.3 which is higher than the minumumapache-airflow
requirement set for Astronomer Providers. This PR adds a typing compat module to be used throughout the repo for consistent typing ofcontext
.