Giter Club home page Giter Club logo

Comments (6)

Stewori avatar Stewori commented on May 28, 2024

@lucaswiman Before you start with this approach, please note that I already did exactly this work. Including support for type variables. Including issubtype. Already supporting older versions of typing module, at least from 3.5.2.2 onwards. Tested with Python 2.7, 3.5, 3.6, 3.6.1 and even Jython.

Implementing this was much more involved than one might expect (e.g. getting things like issubtype(Tuple[int, int, int], Iterable[int]) right.) Honestly NamedTuple is not yet supported, but it is on the agenda. Maybe you could at first try, if the existing approach might be already sufficient (see https://github.com/Stewori/pytypes#is_of_typeobj-cls). If it's not, maybe we can combine our efforts and improve it...?

from typing_inspect.

lucaswiman avatar lucaswiman commented on May 28, 2024

No, that looks fantastic! I searched for something which implements that collection of functionality, and could only find runtime typecheckers.

In the abstract, I think much of your pytypes library would be better in the standard library (or at least linked from the typing documentation), but for my particular interests, your library looks great!

from typing_inspect.

lucaswiman avatar lucaswiman commented on May 28, 2024

In the abstract, I think much of your pytypes library would be better in the standard library

Having read through the documentation in more detail, I guess only a small subset of it makes sense for the standard library, though several of the "Utilities" functions would be good candidates.

from typing_inspect.

ilevkivskyi avatar ilevkivskyi commented on May 28, 2024

After some thinking, it seems to me this should not be in typing_inspect, mainly because it is hard to draw a line between "simple" and "non-simple" runtime checks. Plus there are excellent existing tools mentioned above.

Anyway, thanks for a nice write-up!

from typing_inspect.

lucaswiman avatar lucaswiman commented on May 28, 2024

That's disappointing; I do hope you'll reconsider after the typing library matures. Obviously missing functionality in the standard library leads to a proliferation of incompatible third party libraries of varying quality (c.f. the history of urllib2, requests, etc. where "simple" functionality has a complicated answer as to what you should use.) Python has always advertised itself as "batteries included", and this seems like a glaringly missing battery.

From the perspective of an end user of typing it feels like isinstance is broken, and there's no functionality to replace it. Once pytypes is released on pypi, linking to it in the typing docs would help fill this gap.

Plus there are excellent existing tools mentioned above.

pytypes hasn't been released on pypi and the other tools I could find did not implement this functionality in a simple form, so I disagree with you there. It may be the case in the future, but I don't think it is the case now.

from typing_inspect.

ilevkivskyi avatar ilevkivskyi commented on May 28, 2024

pytypes hasn't been released on pypi and the other tools I could find did not implement this functionality in a simple form, so I disagree with you there. It may be the case in the future, but I don't think it is the case now.

I would say that this is a perfect reason for you to contribute to and improve these projects, so that they will suit your needs. The goal they declare seems to be what you need, while the main goal of typing_inspect is mostly runtime introspection of types themselves.

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.