openai / weak-to-strong

MIT License
2.48k stars 300 forks source link

TypeError: 'type' object is not subscriptable #21

Closed zgimszhd61 closed 7 months ago

zgimszhd61 commented 8 months ago

File "/Users/admin/mywork/weak-to-strong/weak_to_strong/datasets.py", line 19, in _REGISTRY: dict[str, DatasetConfig] = {}

TypeError: 'type' object is not subscriptable

how to solve this problem ?

BlueHephaestus commented 8 months ago

Hey, thanks for raising this issue! Sorry you're having trouble.

That specific line:

_REGISTRY: dict[str, DatasetConfig] = {}

Is actually only compatible with Python 3.9+, since before Python 3.9 you needed to do:

from typing import Dict
_REGISTRY: Dict[str, DatasetConfig] = {}

in order to specify type hints like that. After Python 3.9 you could directly specify type hints like we see in the datasets.py file, but before that you get the error TypeError: 'type' object is not subscriptable which you're experiencing.

I recommend updating to Python 3.9 or higher using https://www.python.org/downloads/ or your preferred package manager and trying it again, that should fix this problem.