-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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 pre-commit check for docstring param types #21398
Conversation
Hats off to @ashb for the original find! |
The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest main at your convenience, or amend the last commit of the PR, and push it with --force-with-lease. |
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.
Ehhhh. Regexp :)
I wish pydocstyle
had a check for it but it does not.
df7569d
to
1d1c196
Compare
|
||
def _check_file(file: Path) -> list: | ||
content = file.read_text() | ||
return re.findall(r' +\:type .+?\:', content) |
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.
Can you add a check for rtype
(return type) also?
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.
Apparently we can't do rtype at this time because not supported by sphinx
I'll try and link relevant pr comment later
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.
see description here #21014 (comment)
1d1c196
to
3883007
Compare
Param types can now be inferred by sphinx from type annotations, so we no longer need them in docstrings. This pre-commit check fails when type declarations are included in docstrings, and seems to do a reasonable job of not catching false positives.
3883007
to
4dc66b6
Compare
Param types can now be inferred by sphinx from type annotations, so we no longer need them in docstrings.
This pre-commit check fails when type declarations are included in docstrings, and seems to do a reasonable job of not catching false positives.
@josh-fell your catches inspired me