Grimmys / rpg_tactical_fantasy_game

A tactical turn-based game project in pygame, open to support
GNU General Public License v3.0
392 stars 85 forks source link

Errors in use of typing module #56

Closed Peleg-Noam closed 1 year ago

Peleg-Noam commented 1 year ago

There seem to be many places where I cannot run the code because of improper use of the typing module.

For example: (position.py) instead of:

from typing import Union

import pygame

Position = Union[pygame.Vector2, tuple[int, int]]

where I get the error: type object is not subscriptable

i need to change it to:

from typing import Union
from typing import Tuple

import pygame

Position = Union[pygame.Vector2, Tuple[int, int]]

this is just one example... am I missing something?

Grimmys commented 1 year ago

Hi,

It's because you are using an old version of Python: https://peps.python.org/pep-0585/ The lower-case types (tuple, list, dict etc.) have been introduced on Python 3.9.

To be still compatible with earlier versions, from __future__ import annotations has to be added in top of the file. Guess I forgot to put it on this file, thanks for the report!

Grimmys commented 1 year ago

Fixed in #03155baa5500659b3462cea42bcbdf9d17a4dc5d