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

PYI066: Decide if the rule should apply for sys.version_info checks in boolean expressions #15347

Open
MichaReiser opened this issue Jan 8, 2025 · 0 comments
Labels
preview Related to preview mode features rule Implementing or modifying a lint rule

Comments

@MichaReiser
Copy link
Member

We considered stabilizing the behavior change that enables PYI066 for nono stub files (see #14059) as part of the 0.9 release (#15340) but ultimately decided against it because we found the following two reports in the ecosystem results:

def _stringify_exception(self, exc: BaseException) -> str:
    try:
        notes = getattr(exc, "__notes__", [])
    except KeyError:
        # Workaround for https://github.com/python/cpython/issues/98778 on
        # Python <= 3.9, and some 3.10 and 3.11 patch versions.
        HTTPError = getattr(sys.modules.get("urllib.error", None), "HTTPError", ())
        if sys.version_info < (3, 12) and isinstance(exc, HTTPError):
            notes = []
        else:
            raise
    tags = WheelTag.compute_best(["x86_64"], py_api="cp39")
    if sys.version_info < (3, 9) or sys.implementation.name != "cpython":
        assert "macosx_10_10_x86_64" in str(tags)
        assert "abi3" not in str(tags)
        assert "cp39" not in str(tags)
    else:
        assert str(tags) == "cp39-abi3-macosx_10_10_x86_64"

While both cases rightfully fall into the scope of the rule, it is fairly opinionated to enforce PYI066. We have to decide if the rule should apply in those cases and, if so, if it should apply both for stub files and regular files.

@MichaReiser MichaReiser added preview Related to preview mode features rule Implementing or modifying a lint rule labels Jan 8, 2025
@MichaReiser MichaReiser changed the title PYI066: Decide if the rule should apply if used in a more complex boolean expression PYI066: Decide if the rule should apply for sys.version checks in boolean expressions Jan 8, 2025
@AlexWaygood AlexWaygood changed the title PYI066: Decide if the rule should apply for sys.version checks in boolean expressions PYI066: Decide if the rule should apply for sys.version_info checks in boolean expressions Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preview Related to preview mode features rule Implementing or modifying a lint rule
Projects
None yet
Development

No branches or pull requests

1 participant