Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ game specific things:
# Changelog

### v1.10
- Linting fixups.
- Moved a few warnings to go through Python's system, so they get attributed to the right place.

### v1.9
- Added a new `CoopSupport.HostOnly` value.
Expand Down
7 changes: 6 additions & 1 deletion mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import inspect
import sys
import warnings
from dataclasses import dataclass, field
from enum import Enum, Flag, auto
from functools import cache
Expand All @@ -19,6 +20,8 @@
if TYPE_CHECKING:
from collections.abc import Callable, Iterator, Sequence

_WARNING_SKIPS: tuple[str] = (str(Path(__file__).parent),)


class Game(Flag):
"""A flags enum of the supported games."""
Expand Down Expand Up @@ -197,9 +200,11 @@ def __post_init__(self) -> None: # noqa: C901 - difficult to split up
case KeybindType() if find_keybinds:
new_keybinds.append(value)
case GroupedOption() | NestedOption() if find_options:
logging.dev_warning(
warnings.warn(
f"{self.name}: {type(value).__name__} instances must be explicitly"
f" specified in the options list!",
stacklevel=2,
skip_file_prefixes=_WARNING_SKIPS,
)
case BaseOption() if find_options:
new_options.append(value)
Expand Down
9 changes: 6 additions & 3 deletions mod_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
import inspect
import operator
import tomllib
import warnings
from collections.abc import Callable, Sequence
from pathlib import Path
from types import ModuleType
from typing import Any, TypedDict

from unrealsdk import logging

from .command import AbstractCommand
from .dot_sdkmod import open_in_mod_dir
from .hook import HookType
Expand All @@ -19,6 +18,8 @@
from .options import BaseOption, GroupedOption, NestedOption
from .settings import SETTINGS_DIR

_WARNING_SKIPS: tuple[str] = (str(Path(__file__).parent),)


def build_mod[T: Mod = Mod](
*,
Expand Down Expand Up @@ -321,9 +322,11 @@ def update_fields_with_module_search( # noqa: C901 - difficult to split up
new_keybinds.append(value)

case GroupedOption() | NestedOption() if find_options:
logging.dev_warning(
warnings.warn(
f"{module.__name__}: {type(value).__name__} instances must be explicitly"
f" specified in the options list!",
stacklevel=2,
skip_file_prefixes=_WARNING_SKIPS,
)
case BaseOption() if find_options:
new_options.append(value)
Expand Down
7 changes: 5 additions & 2 deletions options.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import warnings
from abc import ABC, abstractmethod
from collections.abc import Callable, Mapping, Sequence
from dataclasses import KW_ONLY, dataclass, field
Expand Down Expand Up @@ -136,9 +137,10 @@ def __call__(self, on_change: Callable[[Self, J], None]) -> Self:
This option instance.
"""
if self.on_change is not None:
logging.dev_warning(
warnings.warn(
f"{self.__class__.__qualname__}.__call__ was called on an option which already has"
f" a on change callback.",
stacklevel=2,
)

self.on_change = on_change
Expand Down Expand Up @@ -385,9 +387,10 @@ def __call__(self, on_press: Callable[[Self], None]) -> Self:
This option instance.
"""
if self.on_press is not None:
logging.dev_warning(
warnings.warn(
f"{self.__class__.__qualname__}.__call__ was called on an option which already has"
f" a on press callback.",
stacklevel=2,
)

self.on_press = on_press
Expand Down