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
Yeah it's a tricky one — hard to get a heuristic that covers everything here. My inclination is to say that __module__ is pretty unreliable in a fair few cases actually, and that it's more common for an important re.Pattern to be defined in a module than it is for a __future__.annotations to be accidentally imported via an import *. (This is especially true since generally only packages with type annotations import __future__.annotations, and packages with type annotations generally aren't stubtested for long before being removed from typeshed.)
I would personally either:
Accept that this is a somewhat-rare false positive stubtest is going to have, that will need to be allowlisted; or
Add some special-casing specifically for instances of __future__._Feature, since we can after all basically always guarantee that instances of those objects specifically are never really public API that are being deliberately exported
Activity
AlexWaygood commentedon Jan 26, 2024
Slugify added type hints, with amusing results for stubtest:
I'm guessing #11316 should fix things
JelleZijlstra commentedon Jan 26, 2024
Arguably a stubtest bug too.
hauntsaninja commentedon Jan 26, 2024
Lol
hauntsaninja commentedon Jan 26, 2024
@AlexWaygood any suggestions for how to fix stubtest issue?
It's related to the interesting https://github.com/python/mypy/pull/14270/files#diff-55639a1f38efeacbb10988649399037c13ad11e9c82890b453d98ea2bed9caf8R350
The symtable approach fails here because we get
annotationsfrom some of theimport *. I'm inclined to always listen to__module__if it's present, but that fails for there.compiletest you added...hauntsaninja commentedon Jan 26, 2024
Okay, I found a thing: python/mypy#16823
AlexWaygood commentedon Jan 26, 2024
Yeah it's a tricky one — hard to get a heuristic that covers everything here. My inclination is to say that
__module__is pretty unreliable in a fair few cases actually, and that it's more common for an importantre.Patternto be defined in a module than it is for a__future__.annotationsto be accidentally imported via animport *. (This is especially true since generally only packages with type annotations import__future__.annotations, and packages with type annotations generally aren't stubtested for long before being removed from typeshed.)I would personally either:
__future__._Feature, since we can after all basically always guarantee that instances of those objects specifically are never really public API that are being deliberately exportedAlexWaygood commentedon Jan 26, 2024
Oh, that looks clever! I'll review in a bit once I've had my breakfast
stubtest: adjust symtable logic (#16823)