-
-
Notifications
You must be signed in to change notification settings - Fork 110
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
typing_extensions.Self not working as expected #96
Comments
This technically isn't anything to do with the runtime implementation of typing_extensions (which is what this repo is). mypy just doesn't yet know how to interpret the Self type hint. The next release of mypy should. |
For now you can do:
(note that |
Thanks for the clarification! |
Traceback (most recent call last):
File "/tmp/pycharm_project_710/cnn/train.py", line 23, in <module>
from model.crn import CRN
File "/tmp/pycharm_project_710/cnn/model/crn.py", line 3, in <module>
from torch_geometric.nn import GCNConv
File "/root/miniconda3/lib/python3.8/site-packages/torch_geometric/__init__.py", line 9, in <module>
import torch_geometric.data
File "/root/miniconda3/lib/python3.8/site-packages/torch_geometric/data/__init__.py", line 5, in <module>
from .data import Data
File "/root/miniconda3/lib/python3.8/site-packages/torch_geometric/data/data.py", line 469, in <module>
class Data(BaseData, FeatureStore, GraphStore):
File "/root/miniconda3/lib/python3.8/site-packages/torch_geometric/data/data.py", line 641, in Data
def update(self, data: Union[Self, Dict[str, Any]]) -> Self:
File "/root/miniconda3/lib/python3.8/typing.py", line 261, in inner
return func(*args, **kwds)
File "/root/miniconda3/lib/python3.8/typing.py", line 358, in __getitem__
parameters = tuple(_type_check(p, msg) for p in parameters)
File "/root/miniconda3/lib/python3.8/typing.py", line 358, in <genexpr>
parameters = tuple(_type_check(p, msg) for p in parameters)
File "/root/miniconda3/lib/python3.8/typing.py", line 145, in _type_check
raise TypeError(f"Plain {arg} is not valid as type argument")
TypeError: Plain typing_extensions.Self is not valid as type argument Do you know how to slove the typeerror? |
@liu123liu123liu, it's pretty impossible to tell you how you could "solve" this error without a minimal reproducible example. Even if we had one, it doesn't seem like this error has anything to do with the original issue reported here. If you are able to create a minimal, reproducible example and you're confident that it demonstrates a bug in |
I'm attempting to use
typing_extensions.Self
but finding that it isn't working as expected. I modified the example code here. First, create atest.py
file containing:Then run:
A few things seem wrong to me:
typing_extensions.Self
not valid as a type?y
Self?
and nottest.Foo
?y.a
?Some useful versions to reproduce this:
Python: 3.10.8
typing-extensions: 4.3.0
The text was updated successfully, but these errors were encountered: