Coder Social home page Coder Social logo

Comments (7)

hauntsaninja avatar hauntsaninja commented on September 2, 2024 1

+1 to everything Jelle said. Set mypy's --python-version to the oldest version of Python you'd like to support.

Additionally, note that because typing-extensions is highly special cased, type checkers are not typically aware of differences between versions of typing-extensions and usually pretend that typing-extensions works the way the latest release of typing-extensions did at the time that the version of your type checker was released.

This typically isn't a big deal. If your type checker is much newer than your typing-extensions you might get a false negative which will usually result in an import time error. If your typing-extensions is much newer than your type checker you might get a somewhat false positive, but new symbols in typing-extensions often require special case support in type checkers anyway so it's arguable how false such false positives would be.

Closing, but feel free to ask if you have follow-up questions!

from typing_extensions.

hauntsaninja avatar hauntsaninja commented on September 2, 2024 1

Isn’t setting mypy’s Python version to 3.6 going to prevent me from using the new features in typing extensions?

No

from typing_extensions.

hauntsaninja avatar hauntsaninja commented on September 2, 2024 1

One last note:

mypy dropped support for targeting Python 3.6 in mypy 1.6 (see https://github.com/python/mypy/blob/master/CHANGELOG.md#remove-support-for-targeting-python-36-and-earlier ).

So if you need bleeding edge type system features that only mypy 1.6 and newer support, then you need to choose between a) not using those features, b) upgrading mypy and potentially getting false negatives on Python 3.6

from typing_extensions.

JelleZijlstra avatar JelleZijlstra commented on September 2, 2024

I'm not sure there's much to be said from the typing-extensions side. If you want mypy to check Python 3.6, you should set mypy's python_version to 3.6, and pick an appropriate version of typing-extensions.

from typing_extensions.

tgamblin avatar tgamblin commented on September 2, 2024

I’m still confused by the answer here. I want my code to support python 3.6, but I want to use typing features from newer python versions. Isn’t that the point of typing extensions? Isn’t setting mypy’s Python version to 3.6 going to prevent me from using the new features in typing extensions?

from typing_extensions.

tgamblin avatar tgamblin commented on September 2, 2024

Thanks!

from typing_extensions.

tgamblin avatar tgamblin commented on September 2, 2024

Thanks! My example was somewhat contrived. We support running on Python 3.6-3.12, but we’re currently setting --python-version to 3.7, and haven’t found that mypy admits any annotations that are source-incompatible with 3.6 (I’m not familiar enough to say if there are any).

Most devs are on newer Python versions (3.11, 3.12) and we don’t require that mypy itself be run from Python 3.6.

from typing_extensions.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.