-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some typing errors #44
Comments
Forgot this one. Example 3Code: import datetime
from typing import List, NamedTuple
import enforce
class Example(NamedTuple):
datetime: datetime.datetime
@enforce.runtime_validation
def example() -> List[Example]:
return [Example(datetime.datetime.now())]
example() Traceback:
Can't remember the first time I got this one, sorry (it was with a custom type and not EDIT: just remembered where I found a similar issue: when using forward references as indicated in the PEP/documentation. Code: import enforce
class Example:
@classmethod
@enforce.runtime_validation
def create(cls, *args, **kwargs) -> 'Example':
return cls(*args, **kwargs)
Example.create() |
Right . . . I think they are separate issues but I will address them here.
This is a pretty huge report. It will certainly take time to fix all of them as I am not very free at the moment. Anyway, I will see what I can do given the amount of time I have. Thanks. |
This issue could be split into smaller ones (I can open new ones and close this one), whatever is best for you, I just batched some errors that I encountered while using enforce. The For the generators/iterators/... that's what I thought when I saw the empty tests. :) For |
You are right. Sigh... More work for me. Hahaha. Alright, I will try fixing some of them on the weekend. Anyway, I would prefer to have separate issues. If you can, please split them. Thank you. |
Cheer up, I think this is the most advanced library out there for this kind of thing :) By the way, I'm not sure if Python is really suited/designed for strict typing so maybe you shouldn't try to implement everything. But I do really like to have the ability to 'typecheck' some important parts of the program (for me, this is one of the most annoying thing with Python: even if the ease of development is great, there are too much ways to get bitten and I think enforce allow us to have a little more confidence on some critical parts). |
Hi there, I got some typing errors and I'm not sure where the problems came from, could you give me your thoughts about the following examples?
Feel free to close the issue if there is nothing wrong on enforce's side.
Version used,
pipe show enforce
:Example 1
In this case, there is no problem if the callback is not a bound method.
Code:
This code may raise two different tracebacks, the difference between the two being the type of the function:
The errors go away when the
callback
type is less strict:Is this the expected behavior?
Example 2
The traceback makes me think this may be an error on enforce's side.
Code:
Traceback:
There is a similar problem when a function returns a
Coroutine
.The text was updated successfully, but these errors were encountered: