Nov-08-2021, 06:49 PM
Hello!
I have my own class called ShareData which consist all game settings, images, sounds etc. I pass one instance of ShareData as an __init__ argument(argument name is 'data') to the all other objects in project(game states, game objects etc.) in a few different modules. I use type hints and there i have a question.
How should I type hint 'data' argument if ShareData is in in other module? Should I import ShareData class from another module into all other modules which use it just for writing a type hint? Isn't it form over substance? Example of one class which use argument data:
I have my own class called ShareData which consist all game settings, images, sounds etc. I pass one instance of ShareData as an __init__ argument(argument name is 'data') to the all other objects in project(game states, game objects etc.) in a few different modules. I use type hints and there i have a question.
How should I type hint 'data' argument if ShareData is in in other module? Should I import ShareData class from another module into all other modules which use it just for writing a type hint? Isn't it form over substance? Example of one class which use argument data:
class Projectile(pygame.sprite.Sprite): """Projectile object""" def __init__(self, data: ???, pos_x: int, pos_y: int, style: str) -> None: # Should I import 'from ..control import ShareData' and write 'data: ShareData'? """ Parameters: pos_x: x position where projectile will apear pos_y: y position where projectile will apear style: projectile type """