-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Remove a big chunk of F401. Remove pylint-args from apache-tests. #10096
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
base: main
Are you sure you want to change the base?
Conversation
00bb6c8 to
53928d8
Compare
These were mostly unused unittest and sys from test and setup.py files.
53928d8 to
3b4250b
Compare
|
I wonder why the mocking is not for with mock.patch('certbot._internal.main.sys.stdout', new=output):
with test_util.patch_display_util() as mock_get_utility:
mock_get_utility().notification.side_effect = write_msg
with mock.patch('certbot._internal.main.sys.stderr'):
with pytest.raises(SystemExit):
self._unmocked_parse(args)The local branch I have with Ruff is in atombrella@84d304a This is a POC to replace the custom pylint plugin with flake8-tidy-imports which seems to work. |
|
|
||
| def test_renew_hook_conflict(self): | ||
| with mock.patch("certbot._internal.cli.sys.stderr"): | ||
| with mock.patch("sys.stderr"): |
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'm not really sure why certbot._internal.cli.sys.stderr is required, and not just sys.stderr
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.
tbh i'm not sure why either, although IMO we should either change all occurrences of it or none -- imo none, since it feels unrelated to the rest of the PR
| # NB: Each function defined in compat._path is marked with "type: ignore" to avoid mypy | ||
| # to complain that a function is redefined (because we imported if first from os.path). | ||
|
|
||
| # pylint: disable=function-redefined |
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.
rm this line 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.
pylint complains if I do so.
|
|
||
| try: | ||
| import fcntl # pylint: disable=import-error,unused-import | ||
| import fcntl # pylint: disable=import-error,unused-import # noqa |
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.
having another # in an end-of-line comment feels odd, is it necessary?
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.
ruff is fine with # noqa pylint ... But maybe since ruff/flake8 is not implemented, I can just remove it.
|
|
||
| def test_renew_hook_conflict(self): | ||
| with mock.patch("certbot._internal.cli.sys.stderr"): | ||
| with mock.patch("sys.stderr"): |
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.
tbh i'm not sure why either, although IMO we should either change all occurrences of it or none -- imo none, since it feels unrelated to the rest of the PR
|
@wgreenberg I've updated it. |
These were mostly unused unittest and sys from test-files and setup.py files.
I could move the
# pylint: disable=arguments-differfrom the Apache tests removal to a different PR. The trick to just add**kwargsseems fine, and don't use it.I have a local branch to experiment replacing pylint with Ruff, but there are loads of things that need to be prepared. I have found https://pypi.org/project/flake8-tidy-imports/ that potentially could be used as a replacement for the custom pylint plugin to guard against
import os.My initial idea is to target
E,W,F. Ruff gives instant feedback, and it's pretty powerful. It's also how I found theio.openandOSErrorthings.I have not done anything about this:
You can install
ruffin your local virtual environment, and run:ruff check --select "F401"@bmw has expressed interest in replacing pylint with flake8 to save ~1min in each pipeline.
Besides, there are issues that pylint does not seem to find, e.g., duplicate entries in a dictionary.
Pull Request Checklist