Skip to content

Commit 3d8655e

Browse files
committed
Removal of unnecessary Optional types (#69)
1 parent 47297a7 commit 3d8655e

File tree

2 files changed

+80
-80
lines changed

2 files changed

+80
-80
lines changed

pytiled_parser/tiled_map.py

Lines changed: 78 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,78 @@
1-
"""The tiled_map module contains the primary TiledMap class which represents a single
2-
map from Tiled.
3-
"""
4-
5-
from pathlib import Path
6-
from typing import Dict, List, Optional
7-
8-
import attr
9-
10-
from pytiled_parser.common_types import Color, OrderedPair, Size
11-
from pytiled_parser.layer import Layer
12-
from pytiled_parser.properties import Properties
13-
from pytiled_parser.tileset import Tileset
14-
15-
TilesetDict = Dict[int, Tileset]
16-
17-
18-
@attr.s(auto_attribs=True)
19-
class TiledMap:
20-
"""Object for storing a Tiled map with all associated objects.
21-
22-
This object is the top level object for a map. It contains all layers within a map,
23-
as well as all Tiesets used by the map. When creating an implementation, this will
24-
be the primary class to work with to pull all data relating to a map.
25-
26-
`TMX Reference <https://doc.mapeditor.org/en/stable/reference/tmx-map-format/#map>`_
27-
28-
`JSON Reference <https://doc.mapeditor.org/en/stable/reference/json-map-format/#map>`_
29-
30-
Attributes:
31-
infinite: If the map is infinite or not.
32-
layers: List of layer objects by draw order.
33-
map_size: The map width in tiles.
34-
next_layer_id: Stores the next available ID for new layers.
35-
next_object_id: Stores the next available ID for new objects.
36-
orientation: Map orientation. Tiled supports "orthogonal", "isometric",
37-
"staggered" and "hexagonal"
38-
render_order: The order in which tiles on tile layers are rendered. Valid values
39-
are right-down, right-up, left-down and left-up. In all cases, the map is
40-
drawn row-by-row. (only supported for orthogonal maps at the moment)
41-
tiled_version: The Tiled version used to save the file. May be a date (for
42-
snapshot builds).
43-
tile_size: The size of a tile.
44-
tilesets: Dict of Tileset where Key is the firstgid and the value is the Tileset
45-
version: The JSON format version.
46-
background_color: The background color of the map.
47-
properties: The properties of the Map.
48-
hex_side_length: Only for hexagonal maps. Determines the width or height
49-
(depending on the staggered axis) of the tile's edge, in pixels.
50-
stagger_axis: For staggered and hexagonal maps, determines which axis ("x" or
51-
"y") is staggered.
52-
stagger_index: For staggered and hexagonal maps, determines whether the "even"
53-
or "odd" indexes along the staggered axis are shifted.
54-
class_: The Tiled class of this Map.
55-
parallax_origin: The point on the map to center the parallax scrolling of layers on.
56-
"""
57-
58-
infinite: bool
59-
layers: List[Layer]
60-
map_size: Size
61-
next_layer_id: Optional[int]
62-
next_object_id: int
63-
orientation: str
64-
render_order: str
65-
tiled_version: str
66-
tile_size: Size
67-
tilesets: TilesetDict
68-
version: str
69-
70-
parallax_origin: OrderedPair = OrderedPair(0, 0)
71-
72-
map_file: Optional[Path] = None
73-
class_: Optional[str] = None
74-
background_color: Optional[Color] = None
75-
properties: Optional[Properties] = None
76-
hex_side_length: Optional[int] = None
77-
stagger_axis: Optional[str] = None
78-
stagger_index: Optional[str] = None
1+
"""The tiled_map module contains the primary TiledMap class which represents a single
2+
map from Tiled.
3+
"""
4+
5+
from pathlib import Path
6+
from typing import Dict, List, Optional
7+
8+
import attr
9+
10+
from pytiled_parser.common_types import Color, OrderedPair, Size
11+
from pytiled_parser.layer import Layer
12+
from pytiled_parser.properties import Properties
13+
from pytiled_parser.tileset import Tileset
14+
15+
TilesetDict = Dict[int, Tileset]
16+
17+
18+
@attr.s(auto_attribs=True)
19+
class TiledMap:
20+
"""Object for storing a Tiled map with all associated objects.
21+
22+
This object is the top level object for a map. It contains all layers within a map,
23+
as well as all Tiesets used by the map. When creating an implementation, this will
24+
be the primary class to work with to pull all data relating to a map.
25+
26+
`TMX Reference <https://doc.mapeditor.org/en/stable/reference/tmx-map-format/#map>`_
27+
28+
`JSON Reference <https://doc.mapeditor.org/en/stable/reference/json-map-format/#map>`_
29+
30+
Attributes:
31+
infinite: If the map is infinite or not.
32+
layers: List of layer objects by draw order.
33+
map_size: The map width in tiles.
34+
next_layer_id: Stores the next available ID for new layers.
35+
next_object_id: Stores the next available ID for new objects.
36+
orientation: Map orientation. Tiled supports "orthogonal", "isometric",
37+
"staggered" and "hexagonal"
38+
render_order: The order in which tiles on tile layers are rendered. Valid values
39+
are right-down, right-up, left-down and left-up. In all cases, the map is
40+
drawn row-by-row. (only supported for orthogonal maps at the moment)
41+
tiled_version: The Tiled version used to save the file. May be a date (for
42+
snapshot builds).
43+
tile_size: The size of a tile.
44+
tilesets: Dict of Tileset where Key is the firstgid and the value is the Tileset
45+
version: The JSON format version.
46+
background_color: The background color of the map.
47+
properties: The properties of the Map.
48+
hex_side_length: Only for hexagonal maps. Determines the width or height
49+
(depending on the staggered axis) of the tile's edge, in pixels.
50+
stagger_axis: For staggered and hexagonal maps, determines which axis ("x" or
51+
"y") is staggered.
52+
stagger_index: For staggered and hexagonal maps, determines whether the "even"
53+
or "odd" indexes along the staggered axis are shifted.
54+
class_: The Tiled class of this Map.
55+
parallax_origin: The point on the map to center the parallax scrolling of layers on.
56+
"""
57+
58+
map_file: Path
59+
infinite: bool
60+
layers: List[Layer]
61+
map_size: Size
62+
next_layer_id: Optional[int]
63+
next_object_id: int
64+
orientation: str
65+
render_order: str
66+
tiled_version: str
67+
tile_size: Size
68+
tilesets: TilesetDict
69+
version: str
70+
71+
parallax_origin: OrderedPair = OrderedPair(0, 0)
72+
73+
class_: Optional[str] = None
74+
background_color: Optional[Color] = None
75+
properties: Optional[Properties] = None
76+
hex_side_length: Optional[int] = None
77+
stagger_axis: Optional[str] = None
78+
stagger_index: Optional[str] = None

pytiled_parser/tileset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ class Tile:
121121
opacity: int = 1
122122
x: int = 0
123123
y: int = 0
124-
width: Optional[int] = None
125-
height: Optional[int] = None
124+
width: int = 0
125+
height: int = 0
126126
class_: Optional[str] = None
127127
animation: Optional[List[Frame]] = None
128128
objects: Optional[layer.Layer] = None

0 commit comments

Comments
 (0)