Skip to content

How to solve Python 3.8/3.9 changes in typing representation #126

@stdedos

Description

@stdedos

I am facing some smaller

https://github.com/stdedos/matplotlib-stubs-hoel/actions/runs/6082319105/job/16499842737#step:6:107

E     E: ...], bytes: bool = ...) -> Tuple[float, float, float, float]
E     A: ...], bytes: bool = ...) -> tuple[float, float, float, float]

or bigger problems

https://github.com/stdedos/matplotlib-stubs-hoel/actions/runs/6082319105/job/16499843642#step:6:107

E     E: ...f __call__(self, X: Union[int, float], alpha: Optional[float], bytes:...
E     A: ...f __call__(self, X: int | float, alpha: float | None, bytes: bool = ....

when trying to tox-equivalent test with pytest-mypy-plugins.

Idk; would you be open to exposing e.g. sys.version_info?

Something like

from jinja2 import Environment, FileSystemLoader
import sys

env = Environment(loader=FileSystemLoader('.'))
env.globals['sys'] = {'version_info': sys.version_info}

template = env.get_template('your_template.jinja')

# In your_template.jinja
{% if sys.version_info[0] == 3 %}
  Python 3.x is being used.
{% else %}
  Not using Python 3.x.
{% endif %}

Or, to avoid the X | Y problem:

How can I just No overload variant of "__call__" of "Colormap" matches argument type "{{ rt }}" [call-overload] is asserted, and ignore the notes?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions