Internal error
ArneBachmannDLR opened this issue · 3 comments
Bug report
As mentioned on Twitter, I got disappointing results when trying classes
on my code for the first time, leading to me going back to singledispatch.
What's wrong
I run latest mypy and get:
test.py:8: error: Internal error: attempted lookup of unknown name
test.py:12: error: Internal error: attempted lookup of unknown name
Here is the code:
from classes import typeclass
@typeclass
def listContents(value, path:str, wfile) -> None: pass
@listContents.instance(dict)
def _listContentsDict(value:dict, path:str, wfile) -> None: pass
@listContents.instance(list)
def _listContentsList(value:list, path:str, wfile) -> None: pass
How is that should be
Mypy running successfully.
System information
python
version: Miniforge3 python 3.8.8 environment (same for 3.9)classes
version: 0.3.0mypy
version: 0.902 (0.910 for 3.9)
Hi, @ArneBachmannDLR! I have checked that now it works with the current master
.
Version 0.4.0
will be released soon!
reveal_type(listContents)
# Revealed type is "classes._typeclass._TypeClass[Union[builtins.list[Any], builtins.dict[Any, Any]], def (value: Any, path: builtins.str, wfile: Any), <nothing>, Literal['ex.listContents']]"
Happy to test it soon!
As a sidenode, pulling in external dependencies is usually something I tend to avoid. To commit to a new library there has to be a lot of benefits. I think for classes it would be something like better type safety in mypy and during runtime, right?
Also I think users may be confused by the mention of dry-python
vs. classes
. What is it?
I think for classes it would be something like better type safety in mypy and during runtime, right?
Yes, we have both new runtime features and type-safety features.
Also I think users may be confused by the mention of dry-python vs. classes. What is it?
dry-python
is a family of libraries: https://github.com/dry-python
It also includes returns
and lambdas
at the moment.
I am going to close this issue, since it is solved. But, feel free to ask any questions 🙂