mirror of
https://github.com/enzet/map-machine.git
synced 2025-05-23 14:06:23 +02:00
Add type annotation for __init__.
This commit is contained in:
parent
b20006f6ae
commit
737e434260
17 changed files with 45 additions and 41 deletions
|
@ -132,7 +132,7 @@ class Constructor:
|
|||
check_level=lambda x: True,
|
||||
mode: str = "normal",
|
||||
seed: str = "",
|
||||
):
|
||||
) -> None:
|
||||
self.check_level = check_level
|
||||
self.mode: str = mode
|
||||
self.seed: str = seed
|
||||
|
|
|
@ -62,7 +62,7 @@ class Sector:
|
|||
Sector described by two vectors.
|
||||
"""
|
||||
|
||||
def __init__(self, text: str, angle: Optional[float] = None):
|
||||
def __init__(self, text: str, angle: Optional[float] = None) -> None:
|
||||
"""
|
||||
:param text: sector text representation (e.g. "70-210", "N-NW")
|
||||
:param angle: angle in degrees
|
||||
|
@ -130,7 +130,7 @@ class DirectionSet:
|
|||
Describes direction, set of directions.
|
||||
"""
|
||||
|
||||
def __init__(self, text: str):
|
||||
def __init__(self, text: str) -> None:
|
||||
"""
|
||||
:param text: direction tag value
|
||||
"""
|
||||
|
|
|
@ -60,7 +60,7 @@ class Drawing:
|
|||
Image.
|
||||
"""
|
||||
|
||||
def __init__(self, file_path: Path, width: int, height: int):
|
||||
def __init__(self, file_path: Path, width: int, height: int) -> None:
|
||||
self.file_path: Path = file_path
|
||||
self.width: int = width
|
||||
self.height: int = height
|
||||
|
@ -89,7 +89,7 @@ class SVGDrawing(Drawing):
|
|||
SVG image.
|
||||
"""
|
||||
|
||||
def __init__(self, file_path: Path, width: int, height: int):
|
||||
def __init__(self, file_path: Path, width: int, height: int) -> None:
|
||||
super().__init__(file_path, width, height)
|
||||
self.image = svgwrite.Drawing(str(file_path), (width, height))
|
||||
|
||||
|
@ -131,7 +131,7 @@ class PNGDrawing(Drawing):
|
|||
PNG image.
|
||||
"""
|
||||
|
||||
def __init__(self, file_path: Path, width: int, height: int):
|
||||
def __init__(self, file_path: Path, width: int, height: int) -> None:
|
||||
super().__init__(file_path, width, height)
|
||||
self.surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
|
||||
self.context = cairo.Context(self.surface)
|
||||
|
|
|
@ -28,7 +28,7 @@ class Figure(Tagged):
|
|||
tags: Dict[str, str],
|
||||
inners: List[List[OSMNode]],
|
||||
outers: List[List[OSMNode]],
|
||||
):
|
||||
) -> None:
|
||||
super().__init__()
|
||||
|
||||
self.tags: Dict[str, str] = tags
|
||||
|
@ -72,7 +72,7 @@ class Building(Figure):
|
|||
outers: List[List[OSMNode]],
|
||||
flinger: Flinger,
|
||||
scheme: Scheme,
|
||||
):
|
||||
) -> None:
|
||||
super().__init__(tags, inners, outers)
|
||||
|
||||
style: Dict[str, Any] = {
|
||||
|
@ -192,7 +192,7 @@ class StyledFigure(Figure):
|
|||
inners: List[List[OSMNode]],
|
||||
outers: List[List[OSMNode]],
|
||||
line_style: LineStyle,
|
||||
):
|
||||
) -> None:
|
||||
super().__init__(tags, inners, outers)
|
||||
self.line_style = line_style
|
||||
|
||||
|
@ -208,7 +208,7 @@ class Road(Figure):
|
|||
inners: List[List[OSMNode]],
|
||||
outers: List[List[OSMNode]],
|
||||
matcher: RoadMatcher,
|
||||
):
|
||||
) -> None:
|
||||
super().__init__(tags, inners, outers)
|
||||
self.matcher: RoadMatcher = matcher
|
||||
|
||||
|
@ -243,7 +243,7 @@ class Tree(Tagged):
|
|||
|
||||
def __init__(
|
||||
self, tags: dict[str, str], coordinates: np.array, point: np.array
|
||||
):
|
||||
) -> None:
|
||||
super().__init__(tags)
|
||||
self.coordinates: np.array = coordinates
|
||||
self.point: np.array = point
|
||||
|
@ -269,7 +269,7 @@ class DirectionSector(Tagged):
|
|||
Sector that represents direction.
|
||||
"""
|
||||
|
||||
def __init__(self, tags: dict[str, str], point):
|
||||
def __init__(self, tags: dict[str, str], point) -> None:
|
||||
super().__init__(tags)
|
||||
self.point = point
|
||||
|
||||
|
@ -337,7 +337,7 @@ class Segment:
|
|||
Line segment.
|
||||
"""
|
||||
|
||||
def __init__(self, point_1: np.array, point_2: np.array):
|
||||
def __init__(self, point_1: np.array, point_2: np.array) -> None:
|
||||
self.point_1: np.array = point_1
|
||||
self.point_2: np.array = point_2
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ class Flinger:
|
|||
geo_boundaries: MinMax,
|
||||
scale: float = 18,
|
||||
border: np.array = np.array((0, 0)),
|
||||
):
|
||||
) -> None:
|
||||
"""
|
||||
:param geo_boundaries: minimum and maximum latitude and longitude
|
||||
:param scale: OSM zoom level
|
||||
|
|
|
@ -172,7 +172,9 @@ class ShapeExtractor:
|
|||
Shape is a single path with "id" attribute that aligned to 16×16 grid.
|
||||
"""
|
||||
|
||||
def __init__(self, svg_file_name: Path, configuration_file_name: Path):
|
||||
def __init__(
|
||||
self, svg_file_name: Path, configuration_file_name: Path
|
||||
) -> None:
|
||||
"""
|
||||
:param svg_file_name: input SVG file name with icons. File may contain
|
||||
any other irrelevant graphics.
|
||||
|
|
|
@ -77,7 +77,7 @@ class MapCSSWriter:
|
|||
add_icons: bool = True,
|
||||
add_ways: bool = True,
|
||||
add_icons_for_lifecycle: bool = True,
|
||||
):
|
||||
) -> None:
|
||||
self.add_icons: bool = add_icons
|
||||
self.add_ways: bool = add_ways
|
||||
self.add_icons_for_lifecycle: bool = add_icons_for_lifecycle
|
||||
|
|
|
@ -37,7 +37,7 @@ class Map:
|
|||
overlap: int = 12,
|
||||
mode: str = "normal",
|
||||
label_mode: str = "main",
|
||||
):
|
||||
) -> None:
|
||||
self.overlap: int = overlap
|
||||
self.mode: str = mode
|
||||
self.label_mode: str = label_mode
|
||||
|
|
|
@ -28,7 +28,7 @@ class ArgumentParser(argparse.ArgumentParser):
|
|||
Argument parser that stores arguments and creates help in Moire markup.
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
def __init__(self, *args, **kwargs) -> None:
|
||||
self.arguments: list[dict[str, Any]] = []
|
||||
super(ArgumentParser, self).__init__(*args, **kwargs)
|
||||
|
||||
|
@ -90,7 +90,7 @@ class TestConfiguration:
|
|||
GitHub Actions test configuration.
|
||||
"""
|
||||
|
||||
def __init__(self, test_config: Path):
|
||||
def __init__(self, test_config: Path) -> None:
|
||||
self.steps: dict[str, Any] = {}
|
||||
|
||||
with test_config.open() as input_file:
|
||||
|
@ -177,7 +177,7 @@ class RoentgenHTML(RoentgenMoire, DefaultHTML):
|
|||
Simple HTML.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self) -> None:
|
||||
self.images: dict = {}
|
||||
|
||||
def color(self, args: Arguments) -> str:
|
||||
|
@ -203,7 +203,7 @@ class RoentgenOSMWiki(RoentgenMoire, DefaultWiki):
|
|||
See https://wiki.openstreetmap.org/wiki/Main_Page
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self) -> None:
|
||||
self.images: dict = {}
|
||||
self.extractor: ShapeExtractor = ShapeExtractor(
|
||||
workspace.ICONS_PATH, workspace.ICONS_CONFIG_PATH
|
||||
|
|
|
@ -51,7 +51,7 @@ class Tagged:
|
|||
OpenStreetMap element (node, way or relation) with tags.
|
||||
"""
|
||||
|
||||
def __init__(self, tags: dict[str, str] = None):
|
||||
def __init__(self, tags: dict[str, str] = None) -> None:
|
||||
self.tags: dict[str, str]
|
||||
self.tags = {} if tags is None else tags
|
||||
|
||||
|
@ -104,7 +104,7 @@ class OSMNode(Tagged):
|
|||
See https://wiki.openstreetmap.org/wiki/Node
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
|
||||
self.id_: Optional[int] = None
|
||||
|
@ -162,7 +162,9 @@ class OSMWay(Tagged):
|
|||
See https://wiki.openstreetmap.org/wiki/Way
|
||||
"""
|
||||
|
||||
def __init__(self, id_: int = 0, nodes: Optional[list[OSMNode]] = None):
|
||||
def __init__(
|
||||
self, id_: int = 0, nodes: Optional[list[OSMNode]] = None
|
||||
) -> None:
|
||||
super().__init__()
|
||||
|
||||
self.id_: int = id_
|
||||
|
@ -243,7 +245,7 @@ class OSMRelation(Tagged):
|
|||
See https://wiki.openstreetmap.org/wiki/Relation
|
||||
"""
|
||||
|
||||
def __init__(self, id_: int = 0):
|
||||
def __init__(self, id_: int = 0) -> None:
|
||||
super().__init__()
|
||||
|
||||
self.id_: int = id_
|
||||
|
@ -312,7 +314,7 @@ class OSMData:
|
|||
The whole OpenStreetMap information about nodes, ways, and relations.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self) -> None:
|
||||
self.nodes: dict[int, OSMNode] = {}
|
||||
self.ways: dict[int, OSMWay] = {}
|
||||
self.relations: dict[int, OSMRelation] = {}
|
||||
|
@ -356,7 +358,7 @@ class OverpassReader:
|
|||
See https://wiki.openstreetmap.org/wiki/Overpass_API
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self) -> None:
|
||||
self.osm_data = OSMData()
|
||||
|
||||
def parse_json_file(self, file_name: Path) -> OSMData:
|
||||
|
@ -400,7 +402,7 @@ class OSMReader:
|
|||
parse_ways: bool = True,
|
||||
parse_relations: bool = True,
|
||||
is_full: bool = False,
|
||||
):
|
||||
) -> None:
|
||||
"""
|
||||
:param parse_nodes: whether nodes should be parsed
|
||||
:param parse_ways: whether ways should be parsed
|
||||
|
|
|
@ -23,7 +23,7 @@ class Occupied:
|
|||
texts, shapes).
|
||||
"""
|
||||
|
||||
def __init__(self, width: int, height: int, overlap: float):
|
||||
def __init__(self, width: int, height: int, overlap: float) -> None:
|
||||
self.matrix = np.full((int(width), int(height)), False, dtype=bool)
|
||||
self.width: float = width
|
||||
self.height: float = height
|
||||
|
@ -64,7 +64,7 @@ class Point(Tagged):
|
|||
priority: float = 0,
|
||||
is_for_node: bool = True,
|
||||
draw_outline: bool = True,
|
||||
):
|
||||
) -> None:
|
||||
super().__init__()
|
||||
|
||||
assert point is not None
|
||||
|
|
|
@ -50,7 +50,7 @@ class RoadPart:
|
|||
point_2: np.array,
|
||||
lanes: list[Lane],
|
||||
scale: False,
|
||||
):
|
||||
) -> None:
|
||||
"""
|
||||
:param point_1: start point of the road part
|
||||
:param point_2: end point of the road part
|
||||
|
@ -297,7 +297,7 @@ class Intersection:
|
|||
points of the road parts should be the same.
|
||||
"""
|
||||
|
||||
def __init__(self, parts: list[RoadPart]):
|
||||
def __init__(self, parts: list[RoadPart]) -> None:
|
||||
self.parts: list[RoadPart] = sorted(parts, key=lambda x: x.get_angle())
|
||||
|
||||
for index in range(len(self.parts)):
|
||||
|
|
|
@ -89,7 +89,7 @@ class Matcher:
|
|||
Tag matching.
|
||||
"""
|
||||
|
||||
def __init__(self, structure: dict[str, Any]):
|
||||
def __init__(self, structure: dict[str, Any]) -> None:
|
||||
self.tags: dict[str, str] = structure["tags"]
|
||||
|
||||
self.exception: dict[str, str] = {}
|
||||
|
@ -159,7 +159,7 @@ class NodeMatcher(Matcher):
|
|||
Tag specification matcher.
|
||||
"""
|
||||
|
||||
def __init__(self, structure: dict[str, Any]):
|
||||
def __init__(self, structure: dict[str, Any]) -> None:
|
||||
# Dictionary with tag keys and values, value lists, or "*"
|
||||
super().__init__(structure)
|
||||
|
||||
|
@ -203,7 +203,7 @@ class WayMatcher(Matcher):
|
|||
Special tag matcher for ways.
|
||||
"""
|
||||
|
||||
def __init__(self, structure: dict[str, Any], scheme: "Scheme"):
|
||||
def __init__(self, structure: dict[str, Any], scheme: "Scheme") -> None:
|
||||
super().__init__(structure)
|
||||
self.style: dict[str, Any] = {"fill": "none"}
|
||||
if "style" in structure:
|
||||
|
@ -227,7 +227,7 @@ class RoadMatcher(Matcher):
|
|||
Special tag matcher for highways.
|
||||
"""
|
||||
|
||||
def __init__(self, structure: dict[str, Any], scheme: "Scheme"):
|
||||
def __init__(self, structure: dict[str, Any], scheme: "Scheme") -> None:
|
||||
super().__init__(structure)
|
||||
self.border_color: Color = Color(
|
||||
scheme.get_color(structure["border_color"])
|
||||
|
@ -248,7 +248,7 @@ class Scheme:
|
|||
Specifies map colors and rules to draw icons for OpenStreetMap tags.
|
||||
"""
|
||||
|
||||
def __init__(self, file_name: Path):
|
||||
def __init__(self, file_name: Path) -> None:
|
||||
"""
|
||||
:param file_name: name of the scheme file with tags, colors, and tag key
|
||||
specification
|
||||
|
|
|
@ -21,7 +21,7 @@ class Handler(BaseHTTPRequestHandler):
|
|||
|
||||
def __init__(
|
||||
self, request: bytes, client_address: tuple[str, int], server
|
||||
):
|
||||
) -> None:
|
||||
super().__init__(request, client_address, server)
|
||||
self.cache: Path = Path("cache")
|
||||
self.update_cache: bool = False
|
||||
|
|
|
@ -25,7 +25,7 @@ class TaginfoProjectFile:
|
|||
JSON structure with OpenStreetMap tag usage.
|
||||
"""
|
||||
|
||||
def __init__(self, path: Path, scheme: Scheme):
|
||||
def __init__(self, path: Path, scheme: Scheme) -> None:
|
||||
self.path: Path = path
|
||||
|
||||
self.structure = {
|
||||
|
|
|
@ -47,7 +47,7 @@ class Line:
|
|||
Infinity line: Ax + By + C = 0.
|
||||
"""
|
||||
|
||||
def __init__(self, start: np.array, end: np.array):
|
||||
def __init__(self, start: np.array, end: np.array) -> None:
|
||||
# if start.near(end):
|
||||
# util.error("cannot create line by one point")
|
||||
self.a: float = start[1] - end[1]
|
||||
|
|
|
@ -32,7 +32,7 @@ class Workspace:
|
|||
|
||||
MAPCSS_ICONS_DIRECTORY_NAME: str = "icons"
|
||||
|
||||
def __init__(self, output_path: Path):
|
||||
def __init__(self, output_path: Path) -> None:
|
||||
self.output_path: Path = output_path
|
||||
check_and_create(output_path)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue