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

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

Closed
stdedos opened this issue Sep 5, 2023 · 4 comments
Closed

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

stdedos opened this issue Sep 5, 2023 · 4 comments

Comments

@stdedos
Copy link
Contributor

stdedos commented Sep 5, 2023

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?

@sobolevn
Copy link
Member

sobolevn commented Sep 5, 2023

Try:

force_uppercase_builtins = true
force_union_syntax = true

@stdedos
Copy link
Contributor Author

stdedos commented Sep 5, 2023

Nice finding! ... but it doesn't seem to be included here 😕 https://mypy.readthedocs.io/en/stable/config_file.html

(Also, how about force_lowercase_builtins and force_pipe_syntax? 😝 )

@stdedos stdedos closed this as completed Sep 5, 2023
@sobolevn
Copy link
Member

sobolevn commented Sep 5, 2023

@stdedos please, open a mypy issue about that! I will include them right away!

@stdedos
Copy link
Contributor Author

stdedos commented Sep 5, 2023

@stdedos please, open a mypy issue about that! I will include them right away!

You ... did that already? 😅 python/mypy#16048

Or did you mean a PR for you here? 😕

sobolevn added a commit to python/mypy that referenced this issue Sep 5, 2023
Users don't know about them:
typeddjango/pytest-mypy-plugins#126
Since they are quite important for testing, I think that it is a must to
include them.

---------

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants