ceronman / typeannotations Goto Github PK
View Code? Open in Web Editor NEWA library with a set of tools for annotating types in Python code.
License: Other
A library with a set of tools for annotating types in Python code.
License: Other
I've searched some Python 3 libraries to typecheck using the function annotation, and found this library. I was fascinated by its features, but I got a problem that it wasn't yet uploaded on Python Package Index(PyPI), so I couldn't install it with pip install typeannotations
, and couldn't simply include it as a dependency. Therefore it becomes a huge burden for maintainability. setup.py
was already included in this repository, However, I wonder the reason it wasn't distributed on PyPI.
If you're just deferring the distribution, I wish to mention that anyone can register their packages on PyPI with any unused name without any verifications, and if the name was taken once, it cannot be released as unused until the owner who took the name firstly will drop it or yield it. That's why Pillow have to use different name instead of PIL, and the current maintainer of setuptools had released its enhanced version as a different name, distribute. So if you're willing to upload this library as typeannotations
, I suggest doing it as quick as possible to acquire the name. Although your first release is 0.1.0
or less, it's ok to me. I can deal with it and many people also will do.
This is a great library that will be applicable immediately (unlike mypy), so It can be very helpful to many Python 3 users by a little effort. Please consider uploading it on PyPI.
This is really a question, not an issue: is there a way to implement a type-annotated function that takes arguments of different but compatible types, such as "int" and "float"? I was thinking of the set syntax, such as:
@typechecked def f(x: {int, float}): return x*2
Thank you!
When python runs with -O __debug__
is set to False. This allows the optimizer to remove bytecode that is protected by an if __debug__:
completely. Perhaps providing a @debugtyped
decorator that was protected would be nice for people who only want type checking during development?
Just an idea.
You should allow to write something like that to indicate there is no return (=void)
@typechecked
def rettest(self) -> None:
print("Hello World")
But Actually
Hello World
Traceback (most recent call last):
[...]
File "[...]/annotation/typed.py", line 500, in wrapper
return _check_return_type(signature, target(*args, **kwargs))
File "[...]/annotation/typed.py", line 477, in _check_return_type
raise TypeError('Incorrect return type')
TypeError: Incorrect return type
is thrown and you had to use
@typechecked
def rettest(self) -> type(None):
print("Hello World")
but writing that is ugly and PEP484 defines that
When used in a type hint, the expression None is considered equivalent to type(None) .
so you should also allow None
as type.
This is an alternative to #8 .
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.