-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
map_annotation
when annotation is {list,dict}
instead of `typ…
…ing.{List,Dict}` (#9269) Fixes this error: ```python from dataclasses import dataclass from typing import Dict from torch_geometric.config_store import register @register() @DataClass class MyClass1: something: Dict[str, int] @register() @DataClass class MyClass2: something: dict[str, int] ``` ``` Traceback (most recent call last): File "/home/aki/work/github.com/pyg-team/pytorch_geometric/test_config.py", line 13, in <module> @register() ^^^^^^^^^^ File "/home/aki/work/github.com/pyg-team/pytorch_geometric/torch_geometric/config_store.py", line 360, in bounded_register register(cls=cls, data_cls=data_cls, group=group, **kwargs) File "/home/aki/work/github.com/pyg-team/pytorch_geometric/torch_geometric/config_store.py", line 345, in register data_cls = to_dataclass(cls, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/aki/work/github.com/pyg-team/pytorch_geometric/torch_geometric/config_store.py", line 255, in to_dataclass annotation = map_annotation(annotation, mapping=MAPPING) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/aki/work/github.com/pyg-team/pytorch_geometric/torch_geometric/config_store.py", line 170, in map_annotation annotation.__args__ = tuple(map_annotation(a, mapping) for a in args) ^^^^^^^^^^^^^^^^^^^ AttributeError: readonly attribute ``` --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: rusty1s <matthias.fey@tu-dortmund.de>
- Loading branch information
1 parent
ae185ba
commit 2310348
Showing
4 changed files
with
43 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters