Skip to content

Commit

Permalink
Add __all__ to editoritems
Browse files Browse the repository at this point in the history
  • Loading branch information
TeamSpen210 committed Sep 11, 2023
1 parent 7d32cec commit ea3c972
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/editoritems.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,30 @@
from collections import defaultdict
from collections.abc import Iterable, Iterator, Mapping
from enum import Enum, Flag
from typing import Callable, ClassVar, Protocol, Any
from typing import Callable, ClassVar, Optional, Protocol, Any
from pathlib import PurePosixPath as FSPath

import attrs

from srctools import Vec, logger, conv_int, conv_bool, Keyvalues, Output
from srctools.tokenizer import Tokenizer, Token
from typing_extensions import TypeAlias

from connections import Config as ConnConfig, InputType, OutNames
from editoritems_props import ItemProp, ItemPropKind, PROP_TYPES
from collisions import CollideType, BBox, NonBBoxError
from transtoken import TransToken, TransTokenSource


__all__ = [
"ItemProp", "ItemPropKind", "PROP_TYPES", "ConnConfig", "InputType", "OutNames", # Re-export
"ItemClass", "RenderableType", "Handle", "Surface", "DesiredFacing", "FaceType", "OccuType",
"Sound", "Anim", "ConnTypes", "Connection", "InstCount", "Coord", "EmbedFace", "Overlay",
"ConnSide", "AntlinePoint", "OccupiedVoxel", "Renderable", "SubType", "Item",
]
LOGGER = logger.get_logger(__name__)
# __getstate__ / __setstate__ types.
_SubTypeState: TypeAlias = tuple[str, list[str], list[str], list[int], TransToken, int, int, Optional[FSPath]]


class ItemClass(Enum):
Expand Down Expand Up @@ -688,7 +697,7 @@ def copy(self) -> SubType:

__copy__ = copy

def __deepcopy__(self, memodict: dict | None = None) -> SubType:
def __deepcopy__(self, memodict: dict[int, Any] | None = None) -> SubType:
"""Duplicate this subtype.
We don't need to deep-copy the contents of the containers,
Expand Down Expand Up @@ -725,7 +734,7 @@ def __getstate__(self) -> object:
self.pal_icon,
)

def __setstate__(self, state: tuple) -> None:
def __setstate__(self, state: _SubTypeState) -> None:
self.name, mdls, snds, anims, self.pal_name, x, y, self.pal_icon = state
self.models = list(map(FSPath, mdls))
self.sounds = {
Expand Down Expand Up @@ -1143,7 +1152,7 @@ def _parse_editor_block(self, tok: Tokenizer, pak_id: str) -> None:
def _parse_properties_block(self, tok: Tokenizer, pak_id: str) -> None:
"""Parse the properties block of the item definitions."""
for prop_str in tok.block('Properties'):
prop_type: ItemPropKind | None
prop_type: ItemPropKind[Any] | None
try:
prop_type = PROP_TYPES[prop_str.casefold()]
except KeyError:
Expand Down Expand Up @@ -1911,7 +1920,7 @@ def __getstate__(self) -> tuple:
)

def __setstate__(self, state: tuple) -> None:
props: list[ItemProp]
props: list[ItemProp[Any]]
antline_points: list[list[AntlinePoint]]
(
self.id,
Expand Down

0 comments on commit ea3c972

Please sign in to comment.