-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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-5129] Add typehint to GCP DLP hook #5980
Conversation
3329f09
to
171fef1
Compare
@TobKed Can you do the review? |
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.
I would require adding Optional
when default attribute is None
and suggest removing unnecessary line shortening (no value added).
airflow/gcp/hooks/dlp.py
Outdated
def __init__(self, | ||
gcp_conn_id="google_cloud_default", | ||
delegate_to=None): | ||
def __init__(self, gcp_conn_id="google_cloud_default", delegate_to=None): |
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.
Could you add type hints here as well?
airflow/gcp/hooks/dlp.py
Outdated
): | ||
self, | ||
dlp_job_id: str, | ||
project_id: str = None, |
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.
Could you add Optional
to arguments where default is None
? There is a discussion about using Optional
here [AIRFLOW-5359] Update type annotations in BaseOperator.
Following discussion in python/typing#275, there is a consensus that it is better to require optional types to be made explicit. This PR changes the wording of PEP 484 to allow, but not require, type checkers to treat a None default as implicitly making an argument Optional.
Additional reference: python/peps#689
airflow/gcp/hooks/dlp.py
Outdated
name = DlpServiceClient.organization_deidentify_template_path(organization_id, template_id) | ||
name = DlpServiceClient.organization_deidentify_template_path( | ||
organization_id, template_id | ||
) |
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.
Are these kind of changes required here (shortening the lines)? Since line pylint max-line-length=110
it should be fine as it was. If you use Black I think you should set line length to 110 as well.
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.
I think I set it to 79 as PEP-8 suggested. I'll change it to 110 for this project.
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.
Black by default is set to 88. This value is not obvious. Here is explanation: https://github.com/psf/black#line-length
airflow/gcp/hooks/dlp.py
Outdated
name = DlpServiceClient.organization_deidentify_template_path(organization_id, template_id) | ||
name = DlpServiceClient.organization_deidentify_template_path( | ||
organization_id, template_id | ||
) |
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.
Same as above.
[AIRFLOW-5129] Add typehint to GCP DLP hook
171fef1
to
7a2751c
Compare
@TobKed All updated. |
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.
LGTM. Good job!
cc @mik-laj |
[AIRFLOW-5129] Add typehint to GCP DLP hook
Make sure you have checked all steps below.
Jira
Description
Add typehint to GCP DLP hook airflow/gcp/hooks/dlp.py
Tests
Commits
Documentation
Code Quality
flake8