tmp.py:29: error: Incompatible return value type (got "Callable[[Callable[..., Awaitable[Any]]], Callable[..., Awaitable[Any]]]", expected "Callable[..., Awaitable[Any]]")with this gist https://gist.github.com/Callek/8bca70ffbe560c22dba72b21ecd49ec8
@gaborbernat is it worth re-opening again?
Got very late the notification for this. I think the feature would be very useful in a post no python 2 world too. It's a matter of fact that type annotations make the code more verbose; so there will be projects who don't want to pay the price of this, or projects you can't modify. In this case, you want to provide the type information as stubs... and for maintaining those stubs would be great if you can use some merge-check tool to validate they're correct against the source.
I'm seeing what I think Is a mypy false positive:
def mypy_type_issue(foo: List[str], bar: List[str]) -> Tuple[List[str], List[str]]: new_foo: List[str] new_bar: List[str] pairlis = list(zip(foo, bar)) pairlis.sort(key=lambda x: x) new_foo, new_bar = zip(*pairlis) # ******* return new_foo, new_bar
The line with the asterisks gives me this error:
Incompatible types in assignment (expression has type "Tuple[Any, ...]", variable has type "List[str]"). Is mypy not understanding the
* or am I not understanding mypy? Thanks!
rebelCoderA quick question: When you create a class in python, and when you create instances of that class, is Pyhton smart enough to have just one copy of most of the functions in that class and just link every class instance to the function when it is needed? Or does it make a copy for each instance?
rebelCoder* A quick question: When you create a class in python, and when you create instances of that class, is Python smart enough to have just one copy of most of the functions in that class and just link every class instance to the function when it is needed? Or does it make a copy for each instance?
exceptionarg/kwarg (function has multiple args, exception is not in the first 3) -- it returns
Dict[str, Any]in the nominal case, though if the inner function raises one of a set of predefined exceptions, it raises the passed in exception. HOWEVER if
Noneit doesn't raise an exception and returns
None-- without rewriting logic is there a way to express this in typing?
mypy foo, but it doesn't detect the source files
mypy foo/bar/az/sub_project, but then it doesn't pick up the imports between a.py and b.py correctly
mypy --namespace-packages foo/bar/baz/sub_project. I was almost sure I already checked that. Thanks either way!
rebelCoderHey smart people. Any idea why overloading
__count__method does not work? I have my custom string class and everything else works just fine, but the count method:
def __cout__(self, item): return self.seq.count(item)
# I call: print(test_seq.count('a'))
# Error: print(test_seq.count('a')) AttributeError: 'bio_seq' object has no attribute 'count'
one more question, about configuration now. let's assume such configuration:
foo +-- bar +-- baz +-- sub_project +-- a.py +-- b.py +-- experiment/
where experiment directory contains experimental code, that I don't want to run mypy against.
my mypy config looks like so:
[mypy] namespace_packages=True files=foo/bar/baz/sub_project [mypy-foo.bar.baz.sub_project.experiment.*] ignore_errors=True
and the errors still show up
if I change
[mypy-experiment.*] so that config is as follows, the errors within experiment are ignored:
[mypy] namespace_packages=True files=foo/bar/baz/sub_project [mypy-experiment.*] ignore_errors=True
is that on purpose, that I need to specify the relative path? can I force specifying the full path rather than the relative path?