You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Recognize version guards however sys.version_info is spelled
is_sys_guard only matches the literal 'sys.version_info' attribute
access, so an import guarded by 'from sys import version_info' still
raised import-error when the guarded module was missing. PEP 810
forbids wrapping a lazy import in a try statement (the new
invalid-lazy-import above), which leaves version guards as the pattern
for version-dependent imports, so pylint had better recognize them
reliably.
import-error is only checked once an import has already failed, so the
guard detection can afford to be thorough: the new zealous_is_sys_guard
resolves the compared names instead of matching a spelling, and also
recognizes aliased imports, sys.hexversion, six's PY2/PY3 flags however
six is imported, comparisons putting the version on the right-hand
side, and guards combined with 'and'/'or'/'not'.
The pre-existing is_sys_guard call sites (no-name-in-module,
ungrouped-imports, deprecated-module, used-before-assignment) run on
every import whether it failed or not: they keep the cheap spelling
check, a known tradeoff between cost and thoroughness.
0 commit comments