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

style: pylint #3720

Merged
merged 3 commits into from Feb 15, 2022
Merged

style: pylint #3720

merged 3 commits into from Feb 15, 2022

Conversation

henryiii
Copy link
Collaborator

Description

Builds on #3719, adds pylint, which discovered a mistake in the recent reworking of intree helpers.

Suggested changelog entry:

None needed.

setup.py Outdated
@@ -41,12 +41,10 @@ def build_expected_version_hex(matches: Dict[str, str]) -> str:
serial = int(level_serial[len(level) :])
break
if serial is None:
msg = 'Invalid PYBIND11_VERSION_PATCH: "{}"'.format(patch_level_serial)
msg = f'Invalid PYBIND11_VERSION_PATCH: "{patch_level_serial}"'
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would drop fstrings from here, they will just cause syntax errors if someone tries to pip install from an old setup.py before they hit the version checks, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

(mentioned elsewhere, but repeated more or less here) There are no version checks in setup.py. The Requires-Python setting (in setup.cfg) should keep this from running on an older version. And an f-string failure is a pretty good way to fail - most people know f-strings mean Python 3.6 (it's often the first failure).

.github/CONTRIBUTING.md Outdated Show resolved Hide resolved
@@ -76,8 +82,7 @@ repos:
- id: python-check-blanket-noqa
- id: python-check-blanket-type-ignore
- id: python-no-log-warn
# Python 3.6
# - id: python-use-type-annotations
- id: python-use-type-annotations
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can change a mypy setting to have it complain about these too.

@henryiii henryiii marked this pull request as ready for review February 14, 2022 20:01
@henryiii
Copy link
Collaborator Author

Ready whenever any/every one else is. Does include a fix for a recent regression in intree helpers.

@@ -1,3 +1,5 @@
# pylint: disable=missing-function-docstring
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it would be better to move this to the messages_control.disable list in pyproject.toml.

I often see people writing completely redundant (useless) docstrings just to appease the linter. In my experience it is better left for the review stage, requesting docstrings as needed, if something isn't clear. (Even then, I usually encourage clearer variable and function naming over adding docstrings.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We already have docstrings on everything except __main__ (where they are very much not needed), and I don't expect this to change much. I did disable the module docstring one, as that would be overkill. How about we only disable it (further) if it gets in the way?

Copy link
Collaborator

@rwgk rwgk Feb 15, 2022

Choose a reason for hiding this comment

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

It's fine.
Internally we have our linter configured to warn about function docstrings only if the function is longer than N lines (10 maybe, not sure). I find that useful.
But we can revisit as needed.

@henryiii henryiii merged commit 4b42c37 into pybind:master Feb 15, 2022
@henryiii henryiii deleted the henryiii/style/pylint branch February 15, 2022 22:48
@github-actions github-actions bot added the needs changelog Possibly needs a changelog entry label Feb 15, 2022
@henryiii henryiii removed the needs changelog Possibly needs a changelog entry label Mar 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants