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

CI: Pylint 3.x #3110

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
7 changes: 4 additions & 3 deletions gunicorn/reloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,18 @@ def run(self):


has_inotify = False
inotify = None # inotify.adapters
Inotify = None # inotify.adapters.Inotify
if sys.platform.startswith('linux'):
try:
import inotify.constants as _
from inotify.adapters import Inotify
import inotify.constants
has_inotify = True
except ImportError:
pass
Copy link
Contributor

@cclauss cclauss Aug 12, 2024

Choose a reason for hiding this comment

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

The other changes are not needed to placate pylint.

Suggested change
pass
inotify = None

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Almost, because we have two conditionals (the remainder of the sys.platform branch must be covered aswell) and import two things. But while mypy hates this, pylint seems OK with being tricked by the two-line version, see https://github.com/benoitc/gunicorn/pull/3110/files#diff-f807d81a0dfb3d826a7b566e4902c676f12447b6d5c442d4c291edca727b6cb5



if has_inotify:
from inotify.adapters import Inotify
import inotify.constants

class InotifyReloader(threading.Thread):
event_mask = (inotify.constants.IN_CREATE | inotify.constants.IN_DELETE
Expand Down
Loading