Giter Club home page Giter Club logo

Comments (6)

thatch avatar thatch commented on May 28, 2024

This same bug has far-reaching effects and is the cause of Instagram/LibCST#305 as well.

from typing_inspect.

thatch avatar thatch commented on May 28, 2024

This is a little more interesting, and mainly appears to affect unsubscripted types that ought to be considered generic. In 3.8, these have __args__ with TypeVar; in 3.9 there's only _nargs.

If we apply the trivial fix to consider unsubscripted types to be generic as well, we get a predictable AttributeError. If we return empty-tuple, that's a behavior change, and I'd like to have others weigh in on whether this is a bug in upstream 3.9, and whether get_args returning empty-tuple is good enough. That would work for the current implementation in LibCST, since it just skips further validation.

from typing_inspect.

thatch avatar thatch commented on May 28, 2024

Jelle, I had a conversation with Łukasz and I don't feel like we have buy-in on this being a cpython bug. I don't think there's a way to fix this in typing_inspect, can you help me with considering fixes and escalating?

from typing_inspect.

ilevkivskyi avatar ilevkivskyi commented on May 28, 2024

FWIW, a potential fix can be hard-coding some special cases. Technically, typing_inspect uses a bunch of private APIs to provide a bit deeper level of introspection than the one provided by typing, so I can see why this is not an upstream bug.

I may not have time to work on this soon, but if someone has ideas for a robust fix, I will be glad to merge a PR.

from typing_inspect.

JelleZijlstra avatar JelleZijlstra commented on May 28, 2024

Similar to what Ivan said, I'm not sure why this can't be fixed in typing-inspect, for example by looking for the _SpecialGenericAlias class inside the implementation of is_generic_type().

I ran into this doing some runtime type inspection in pyanalyze and worked around it with some 3.9-specific code: https://github.com/quora/pyanalyze/blob/master/pyanalyze/annotations.py#L225.

Is there a bugs.python.org issue about this?

from typing_inspect.

baldurmen avatar baldurmen commented on May 28, 2024

FWIW, this means I can't build typing_inspect in Debian anymore :(

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=972803

Hopefully someone can implement a fix soonish, since it won't move from unstable to testing until this is fixed.

from typing_inspect.

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.