mirror of
https://github.com/OMGeeky/pytiled_parser.git
synced 2025-12-26 17:02:28 +01:00
Mypy cleanup
This commit is contained in:
@@ -126,6 +126,19 @@ def parse(file: Path) -> TiledMap:
|
||||
layers = [layer for layer in map_.layers if hasattr(layer, "tiled_objects")]
|
||||
|
||||
for my_layer in layers:
|
||||
# Mypy extremely hates what is going on in this whole block
|
||||
# For some reason an ignore on this first for loop is causing it
|
||||
# to just not care about any of the problems in here.
|
||||
# However, under normal circumstances, mypy hates just about every
|
||||
# line of this block.
|
||||
#
|
||||
# This is because we are doing some run-time modification of the attributes
|
||||
# on the tiled_object class and making assumptions about things based on that.
|
||||
# This is done to achieve a system where we can load-in tilesets which were
|
||||
# defined in a Tiled Object Template. This is tough because we need to know what
|
||||
# tilesets have been loaded in already, and use them if they have been, but then
|
||||
# be able to dynamically add-in tilesets after having parsed the rest of the map.
|
||||
|
||||
for tiled_object in my_layer.tiled_objects: # type: ignore
|
||||
if hasattr(tiled_object, "new_tileset"):
|
||||
if tiled_object.new_tileset is not None:
|
||||
|
||||
@@ -49,7 +49,7 @@ RawTile = TypedDict(
|
||||
"objectgroup": RawLayer,
|
||||
},
|
||||
)
|
||||
RawTile.__docs__ = """
|
||||
RawTile.__doc__ = """
|
||||
The keys and their types that appear in a Tile JSON Object.
|
||||
"""
|
||||
|
||||
|
||||
@@ -369,3 +369,5 @@ def parse(
|
||||
return _parse_image_layer(raw_layer)
|
||||
elif type_ == "layer":
|
||||
return _parse_tile_layer(raw_layer)
|
||||
else:
|
||||
raise RuntimeError("Unknown layer type in map file!")
|
||||
|
||||
@@ -13,7 +13,12 @@ def parse(raw_properties: etree.Element) -> Properties:
|
||||
for raw_property in raw_properties.findall("property"):
|
||||
|
||||
type_ = raw_property.attrib.get("type")
|
||||
value_ = raw_property.attrib.get("value")
|
||||
|
||||
if "value" not in raw_property.attrib:
|
||||
continue
|
||||
|
||||
value_ = raw_property.attrib["value"]
|
||||
|
||||
if type_ == "file":
|
||||
value = Path(value_)
|
||||
elif type_ == "color":
|
||||
|
||||
@@ -84,7 +84,20 @@ def parse(file: Path) -> TiledMap:
|
||||
layers = [layer for layer in map_.layers if hasattr(layer, "tiled_objects")]
|
||||
|
||||
for my_layer in layers:
|
||||
for tiled_object in my_layer.tiled_objects:
|
||||
# Mypy extremely hates what is going on in this whole block
|
||||
# For some reason an ignore on this first for loop is causing it
|
||||
# to just not care about any of the problems in here.
|
||||
# However, under normal circumstances, mypy hates just about every
|
||||
# line of this block.
|
||||
#
|
||||
# This is because we are doing some run-time modification of the attributes
|
||||
# on the tiled_object class and making assumptions about things based on that.
|
||||
# This is done to achieve a system where we can load-in tilesets which were
|
||||
# defined in a Tiled Object Template. This is tough because we need to know what
|
||||
# tilesets have been loaded in already, and use them if they have been, but then
|
||||
# be able to dynamically add-in tilesets after having parsed the rest of the map.
|
||||
|
||||
for tiled_object in my_layer.tiled_objects: # type: ignore
|
||||
if hasattr(tiled_object, "new_tileset"):
|
||||
if tiled_object.new_tileset is not None:
|
||||
already_loaded = None
|
||||
|
||||
19
setup.cfg
19
setup.cfg
@@ -77,25 +77,10 @@ line_length=88
|
||||
# Global options:
|
||||
|
||||
[mypy]
|
||||
python_version = 3.6
|
||||
python_version = 3.10
|
||||
warn_unused_configs = True
|
||||
warn_redundant_casts = True
|
||||
|
||||
# Per-module options:
|
||||
[mypy-pytiled_parser.*]
|
||||
disallow_any_unimported = True
|
||||
disallow_any_decorated = True
|
||||
disallow_any_generics = True
|
||||
disallow_subclassing_any = True
|
||||
disallow_untyped_calls = True
|
||||
disallow_untyped_defs = True
|
||||
disallow_incomplete_defs = True
|
||||
check_untyped_defs = True
|
||||
disallow_untyped_decorators = True
|
||||
warn_return_any = True
|
||||
warn_unused_ignores = True
|
||||
no_implicit_optional = True
|
||||
strict_optional = True
|
||||
ignore_missing_imports = True
|
||||
|
||||
[mypy-tests.*]
|
||||
ignore_errors = True
|
||||
|
||||
Reference in New Issue
Block a user