From 8b970f84136202f1a3d136fef9c15e8a504b65af Mon Sep 17 00:00:00 2001 From: Jouramie Date: Sun, 22 Sep 2024 12:05:07 -0400 Subject: [PATCH] remove 3.8 old garbage --- worlds/stardew_valley/content/unpacking.py | 6 +----- worlds/stardew_valley/data/artisan.py | 4 ++-- worlds/stardew_valley/data/game_item.py | 18 ++++-------------- worlds/stardew_valley/data/harvest.py | 17 ++++++++--------- worlds/stardew_valley/data/shop.py | 13 ++++++------- worlds/stardew_valley/data/skill.py | 4 +--- worlds/stardew_valley/items.py | 5 +---- worlds/stardew_valley/locations.py | 5 +---- worlds/stardew_valley/requirements.txt | 2 -- .../test/stability/TestStability.py | 2 -- 10 files changed, 24 insertions(+), 52 deletions(-) delete mode 100644 worlds/stardew_valley/requirements.txt diff --git a/worlds/stardew_valley/content/unpacking.py b/worlds/stardew_valley/content/unpacking.py index f069866d56cd..3c57f91afe3a 100644 --- a/worlds/stardew_valley/content/unpacking.py +++ b/worlds/stardew_valley/content/unpacking.py @@ -1,16 +1,12 @@ from __future__ import annotations +from graphlib import TopologicalSorter from typing import Iterable, Mapping, Callable from .game_content import StardewContent, ContentPack, StardewFeatures from .vanilla.base import base_game as base_game_content_pack from ..data.game_item import GameItem, ItemSource -try: - from graphlib import TopologicalSorter -except ImportError: - from graphlib_backport import TopologicalSorter # noqa - def unpack_content(features: StardewFeatures, packs: Iterable[ContentPack]) -> StardewContent: # Base game is always registered first. diff --git a/worlds/stardew_valley/data/artisan.py b/worlds/stardew_valley/data/artisan.py index 593ab6a3ddf0..90be5b1684f0 100644 --- a/worlds/stardew_valley/data/artisan.py +++ b/worlds/stardew_valley/data/artisan.py @@ -1,9 +1,9 @@ from dataclasses import dataclass -from .game_item import kw_only, ItemSource +from .game_item import ItemSource -@dataclass(frozen=True, **kw_only) +@dataclass(frozen=True, kw_only=True) class MachineSource(ItemSource): item: str # this should be optional (worm bin) machine: str diff --git a/worlds/stardew_valley/data/game_item.py b/worlds/stardew_valley/data/game_item.py index 6c8d30ed8e6f..c6e4717cd1e0 100644 --- a/worlds/stardew_valley/data/game_item.py +++ b/worlds/stardew_valley/data/game_item.py @@ -1,5 +1,4 @@ import enum -import sys from abc import ABC from dataclasses import dataclass, field from types import MappingProxyType @@ -7,11 +6,6 @@ from ..stardew_rule.protocol import StardewRule -if sys.version_info >= (3, 10): - kw_only = {"kw_only": True} -else: - kw_only = {} - DEFAULT_REQUIREMENT_TAGS = MappingProxyType({}) @@ -36,21 +30,17 @@ class ItemTag(enum.Enum): class ItemSource(ABC): add_tags: ClassVar[Tuple[ItemTag]] = () + other_requirements: Tuple[Requirement, ...] = field(kw_only=True, default_factory=tuple) + @property def requirement_tags(self) -> Mapping[str, Tuple[ItemTag, ...]]: return DEFAULT_REQUIREMENT_TAGS - # FIXME this should just be an optional field, but kw_only requires python 3.10... - @property - def other_requirements(self) -> Iterable[Requirement]: - return () - -@dataclass(frozen=True, **kw_only) +@dataclass(frozen=True, kw_only=True) class GenericSource(ItemSource): regions: Tuple[str, ...] = () """No region means it's available everywhere.""" - other_requirements: Tuple[Requirement, ...] = () @dataclass(frozen=True) @@ -59,7 +49,7 @@ class CustomRuleSource(ItemSource): create_rule: Callable[[Any], StardewRule] -@dataclass(frozen=True, **kw_only) +@dataclass(frozen=True, kw_only=True) class CompoundSource(ItemSource): sources: Tuple[ItemSource, ...] = () diff --git a/worlds/stardew_valley/data/harvest.py b/worlds/stardew_valley/data/harvest.py index 087d7c3fa86b..0fdae9549587 100644 --- a/worlds/stardew_valley/data/harvest.py +++ b/worlds/stardew_valley/data/harvest.py @@ -1,18 +1,17 @@ from dataclasses import dataclass from typing import Tuple, Sequence, Mapping -from .game_item import ItemSource, kw_only, ItemTag, Requirement +from .game_item import ItemSource, ItemTag from ..strings.season_names import Season -@dataclass(frozen=True, **kw_only) +@dataclass(frozen=True, kw_only=True) class ForagingSource(ItemSource): regions: Tuple[str, ...] seasons: Tuple[str, ...] = Season.all - other_requirements: Tuple[Requirement, ...] = () -@dataclass(frozen=True, **kw_only) +@dataclass(frozen=True, kw_only=True) class SeasonalForagingSource(ItemSource): season: str days: Sequence[int] @@ -22,17 +21,17 @@ def as_foraging_source(self) -> ForagingSource: return ForagingSource(seasons=(self.season,), regions=self.regions) -@dataclass(frozen=True, **kw_only) +@dataclass(frozen=True, kw_only=True) class FruitBatsSource(ItemSource): ... -@dataclass(frozen=True, **kw_only) +@dataclass(frozen=True, kw_only=True) class MushroomCaveSource(ItemSource): ... -@dataclass(frozen=True, **kw_only) +@dataclass(frozen=True, kw_only=True) class HarvestFruitTreeSource(ItemSource): add_tags = (ItemTag.CROPSANITY,) @@ -46,7 +45,7 @@ def requirement_tags(self) -> Mapping[str, Tuple[ItemTag, ...]]: } -@dataclass(frozen=True, **kw_only) +@dataclass(frozen=True, kw_only=True) class HarvestCropSource(ItemSource): add_tags = (ItemTag.CROPSANITY,) @@ -61,6 +60,6 @@ def requirement_tags(self) -> Mapping[str, Tuple[ItemTag, ...]]: } -@dataclass(frozen=True, **kw_only) +@dataclass(frozen=True, kw_only=True) class ArtifactSpotSource(ItemSource): amount: int diff --git a/worlds/stardew_valley/data/shop.py b/worlds/stardew_valley/data/shop.py index f14dbac82131..cc9506023f19 100644 --- a/worlds/stardew_valley/data/shop.py +++ b/worlds/stardew_valley/data/shop.py @@ -1,40 +1,39 @@ from dataclasses import dataclass from typing import Tuple, Optional -from .game_item import ItemSource, kw_only, Requirement +from .game_item import ItemSource from ..strings.season_names import Season ItemPrice = Tuple[int, str] -@dataclass(frozen=True, **kw_only) +@dataclass(frozen=True, kw_only=True) class ShopSource(ItemSource): shop_region: str money_price: Optional[int] = None items_price: Optional[Tuple[ItemPrice, ...]] = None seasons: Tuple[str, ...] = Season.all - other_requirements: Tuple[Requirement, ...] = () def __post_init__(self): assert self.money_price is not None or self.items_price is not None, "At least money price or items price need to be defined." assert self.items_price is None or all(isinstance(p, tuple) for p in self.items_price), "Items price should be a tuple." -@dataclass(frozen=True, **kw_only) +@dataclass(frozen=True, kw_only=True) class MysteryBoxSource(ItemSource): amount: int -@dataclass(frozen=True, **kw_only) +@dataclass(frozen=True, kw_only=True) class ArtifactTroveSource(ItemSource): amount: int -@dataclass(frozen=True, **kw_only) +@dataclass(frozen=True, kw_only=True) class PrizeMachineSource(ItemSource): amount: int -@dataclass(frozen=True, **kw_only) +@dataclass(frozen=True, kw_only=True) class FishingTreasureChestSource(ItemSource): amount: int diff --git a/worlds/stardew_valley/data/skill.py b/worlds/stardew_valley/data/skill.py index d0674f34c0e1..4c754ddd8716 100644 --- a/worlds/stardew_valley/data/skill.py +++ b/worlds/stardew_valley/data/skill.py @@ -1,9 +1,7 @@ from dataclasses import dataclass, field -from ..data.game_item import kw_only - @dataclass(frozen=True) class Skill: name: str - has_mastery: bool = field(**kw_only) + has_mastery: bool = field(kw_only=True) diff --git a/worlds/stardew_valley/items.py b/worlds/stardew_valley/items.py index 31c7da5e3ade..ac337940ec30 100644 --- a/worlds/stardew_valley/items.py +++ b/worlds/stardew_valley/items.py @@ -124,10 +124,7 @@ def __call__(self, item: Item): def load_item_csv(): - try: - from importlib.resources import files - except ImportError: - from importlib_resources import files # noqa + from importlib.resources import files items = [] with files(data).joinpath("items.csv").open() as file: diff --git a/worlds/stardew_valley/locations.py b/worlds/stardew_valley/locations.py index 43246a94a356..1d67d535ccee 100644 --- a/worlds/stardew_valley/locations.py +++ b/worlds/stardew_valley/locations.py @@ -130,10 +130,7 @@ def __call__(self, name: str, code: Optional[int], region: str) -> None: def load_location_csv() -> List[LocationData]: - try: - from importlib.resources import files - except ImportError: - from importlib_resources import files + from importlib.resources import files with files(data).joinpath("locations.csv").open() as file: reader = csv.DictReader(file) diff --git a/worlds/stardew_valley/requirements.txt b/worlds/stardew_valley/requirements.txt deleted file mode 100644 index 65e922a64483..000000000000 --- a/worlds/stardew_valley/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -importlib_resources; python_version <= '3.8' -graphlib_backport; python_version <= '3.8' diff --git a/worlds/stardew_valley/test/stability/TestStability.py b/worlds/stardew_valley/test/stability/TestStability.py index 8bb904a56ea2..137a7172aff4 100644 --- a/worlds/stardew_valley/test/stability/TestStability.py +++ b/worlds/stardew_valley/test/stability/TestStability.py @@ -12,8 +12,6 @@ # at 0x102ca98a0> lambda_regex = re.compile(r"^ at (.*)>$") -# Python 3.10.2\r\n -python_version_regex = re.compile(r"^Python (\d+)\.(\d+)\.(\d+)\s*$") class TestGenerationIsStable(SVTestCase):