Skip to content
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

apply_default keeps the function signature for mypy #9784

Merged
merged 3 commits into from
Jul 22, 2020

Conversation

mik-laj
Copy link
Member

@mik-laj mik-laj commented Jul 12, 2020

apply default cleared all information about constructor parameter types. I fixed it by using generic. This revealed some type inaccuracies that were previously hidden.

In addition, there was a problem with "multiple values for keyword argument"
python/mypy#6799
so I deleted the args parameter in several places to suit mypy. We probably should do it for all operators, but I would prefer to do it in a separate ticket.


Make sure to mark the boxes below before creating PR: [x]

  • Description above provides context of the change
  • Unit tests coverage for changes (not needed for documentation changes)
  • Target Github ISSUE in description if exists
  • Commits follow "How to write a good git commit message"
  • Relevant documentation is updated including usage instructions.
  • I will engage committers as explained in Contribution Workflow Example.

In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.
Read the Pull Request Guidelines for more information.

@boring-cyborg boring-cyborg bot added k8s provider:amazon AWS/Amazon - related issues provider:google Google (including GCP) related issues labels Jul 12, 2020
@mik-laj mik-laj force-pushed the apply-default-sign branch from d27e5e1 to 2e302ba Compare July 12, 2020 21:40

from airflow.exceptions import AirflowException

signature = inspect.signature

T = TypeVar('T', bound=Callable) # pylint: disable=invalid-name
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the most interesting part.

Copy link
Member

@turbaszek turbaszek Jul 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand it. I'm wondering if removing the @apply_defulats will solve the same issue? I think now we have BaseOperatorMeta we can consider removing this decorator.

Copy link
Member Author

@mik-laj mik-laj Jul 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will solve it because mypy is not smart enough to look into the metaclass, but we will still have remaining problems to solve. I consider it an intermediate solution until we cannot use the metaclass.

return filecmp.cmp(qubole_result_1, qubole_result_2)

t1 = QuboleOperator(
hive_show_table = QuboleOperator(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems as unrelated change but lets keep it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a related change. The variable t1 was used in this file, but once it had one operator and then another decorator. Mypy then reported that the variable type is invalid.
To solve this problem I had to enter more descriptive variable names.
https://github.com/apache/airflow/blob/2be7efa5c023d96f4266df67c7da2e90020e16f9%5E%5E%5E%5E/airflow/providers/qubole/example_dags/example_qubole.py#L255
https://github.com/apache/airflow/blob/2be7efa5c023d96f4266df67c7da2e90020e16f9%5E%5E%5E%5E/airflow/providers/qubole/example_dags/example_qubole.py#L72

@mik-laj mik-laj force-pushed the apply-default-sign branch from 040c69d to 97e323c Compare July 13, 2020 12:44
@mik-laj mik-laj force-pushed the apply-default-sign branch from 97e323c to f9c4b68 Compare July 22, 2020 00:35
@mik-laj mik-laj force-pushed the apply-default-sign branch from 9d3ee7d to b32d842 Compare July 22, 2020 11:58
@mik-laj mik-laj merged commit 33f0cd2 into apache:master Jul 22, 2020
@mik-laj mik-laj deleted the apply-default-sign branch July 22, 2020 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
provider:amazon AWS/Amazon - related issues provider:google Google (including GCP) related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants