Skip to content

[stubtest] ignore __conditional_annotations__#20392

Merged
JelleZijlstra merged 1 commit into
python:masterfrom
jorenham:stubtest/__conditional_annotations__
Dec 10, 2025
Merged

[stubtest] ignore __conditional_annotations__#20392
JelleZijlstra merged 1 commit into
python:masterfrom
jorenham:stubtest/__conditional_annotations__

Conversation

@jorenham

Copy link
Copy Markdown
Contributor

On Python 3.14, this module attribute seems to exist in certain situations:

>>> if True:
...     a: str
...     
>>> __conditional_annotations__
{0}

It's a pretty esoteric attribute without any documentation. It seems to have been added in python/cpython#130935

Either way, stubtest was complaining about it in scipy-stubs. So all things considered, I figured it'd be best to just ignore it.

@JelleZijlstra JelleZijlstra merged commit dabcce9 into python:master Dec 10, 2025
16 checks passed
@jorenham jorenham deleted the stubtest/__conditional_annotations__ branch December 10, 2025 14:28
@github-project-automation github-project-automation Bot moved this from Todo to Done in GC-Content-Calculator Dec 12, 2025
@jungerm2

Copy link
Copy Markdown

I'm getting a module.__conditional_annotations__ is not present in stub error, when using mypy 1.19.1 in python 3.14.0. That mypy version was released just a few days after this fix was merged in, does it not contain it? Is there a temporary fix in the meantime I could use?

@jorenham

jorenham commented Jan 15, 2026

Copy link
Copy Markdown
Contributor Author

1.19.1 indeed doesn't this: https://github.com/python/mypy/commits/v1.19.1/

Is there a temporary fix in the meantime I could use?

You could annotate it, or put it in an allowlist.

@jungerm2

Copy link
Copy Markdown

Any workaround until the next release?

@jorenham

Copy link
Copy Markdown
Contributor Author

Like I said, you could annotate it, or put it in an allowlist.
Here's what I did in scipy-stubs: https://github.com/scipy/scipy-stubs/blob/423767dd63020d29de36ed63278d3ed1f03d47ab/scipy-stubs/special/_add_newdocs.pyi#L5-L7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants