Skip to content

Tweak Optional types so that type assertions in arcade are not necessary #69

Closed
@cspotcode

Description

@cspotcode

There are two different Optional types in pytiled_parser affecting us in pythonarcade/arcade#1751

Based on discussion, these types can be made non-optional in pytiled_parser which will (eventually) eliminate the need for the downstream assertions in arcade.

Discord conversation:
https://discord.com/channels/458662222697070613/458662458198982676/1108508437832270034

Tile.width and Tile.height are Optional

width: Optional[int] = None
height: Optional[int] = None

So we use type assertions here:
https://github.com/pythonarcade/arcade/blob/4d7d846b5c853a509ae818bf98152623451eeb6f/arcade/tilemap/tilemap.py#L70-L73

TiledMap.map_file is Optional

map_file: Optional[Path] = None

So we use a type assertion here:
https://github.com/pythonarcade/arcade/blob/4d7d846b5c853a509ae818bf98152623451eeb6f/arcade/tilemap/tilemap.py#L419-L421

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions