GithubHelp home page GithubHelp logo

Usage with `typing.NamedTuple` about enforce HOT 4 CLOSED

russbaz avatar russbaz commented on May 18, 2024
Usage with `typing.NamedTuple`

from enforce.

Comments (4)

RussBaz avatar RussBaz commented on May 18, 2024 1

Thanks for trying it out!

It is an interesting problem. As it turns out, this is a problem with blindly attempting to enforce runtime type safety on every attribute of a given class (especially if it inherits from an inbuilt class).

It will be possible to use named tuples as a type hint in the functions. However, it will be slightly harder to make named tuples truly typed.

I have some ideas how it can be done. I will look at it over the coming weekend and will keep you updated.

from enforce.

Tarrasch avatar Tarrasch commented on May 18, 2024 1

As I don't consider myself a power user yet, I'll wait for some sort of pypi release. But thanks for implementing this!

from enforce.

RussBaz avatar RussBaz commented on May 18, 2024 1

I am sorry for the long delay but the pypi version of Enforce.py was just updated to 0.3.2. This version includes all the fixes for the NamedTuples and adds a support for Python 3.5.3 and 3.6.0.

Please have a look if you are still interested.

from enforce.

RussBaz avatar RussBaz commented on May 18, 2024

OK, I just pushed a patch into 'dev' branch enabling your specific use case of NamedTuples. Full support for named tuples (i.e. named tuple as a type hint) will be coming a bit later.

from enforce.

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.