Skip to content

Commit

Permalink
Significant cleanup x 15.
Browse files Browse the repository at this point in the history
This commit is the next in a commit chain quietly resurrecting BETSE
for a modern audience and the modern Python ecosystem. Specifically,
this commit continues resolving failing GitHub Actions-based continuous
integration (CI) workflows. BETSE 1.4.0 is now still days from official
release, supposedly. (*Despised reprisals!*)
  • Loading branch information
leycec committed Sep 23, 2024
1 parent 207fcb3 commit a8aea09
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
9 changes: 3 additions & 6 deletions betse/util/io/error/errwarning.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@

# ....................{ IMPORTS }....................
import sys, warnings
from beartype.typing import (
ContextManager,
Generator,
)
from betse.util.io.log import logs
from betse.util.type.types import ClassType
from betse.util.type.typehints import ContextManagerOrGenerator
from contextlib import contextmanager

# ....................{ INITIALIZERS }....................
Expand Down Expand Up @@ -82,7 +79,7 @@ def init() -> None:
logs.log_debug('Deferring to default warning policy.')

# ....................{ MANAGERS }....................
def ignoring_deprecations() -> ContextManager:
def ignoring_deprecations() -> ContextManagerOrGenerator:
'''
Single-shot context manager temporarily ignoring all **deprecation
warnings** (i.e., instances of the :class:`DeprecationWarning`,
Expand All @@ -104,7 +101,7 @@ def ignoring_deprecations() -> ContextManager:


@contextmanager
def ignoring_warnings(*warning_clses: ClassType) -> Generator:
def ignoring_warnings(*warning_clses: ClassType) -> ContextManagerOrGenerator:
'''
Single-shot context manager temporarily ignoring *all* warnings of *all*
passed warning types emitted by the :mod:`warnings` module for the duration
Expand Down
8 changes: 8 additions & 0 deletions betse/util/type/typehints.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,21 @@
# ....................{ IMPORTS }....................
from beartype.typing import (
Annotated,
ContextManager,
Generator,
)
from beartype.vale import (
IsAttr,
IsEqual,
)
from numpy import ndarray

# ....................{ HINTS }....................
ContextManagerOrGenerator = ContextManager | Generator
'''
PEP-compliant type hint matching either a context manager *or* generator.
'''

# ....................{ HINTS ~ lib : numpy : 1d }....................
NDArrayNdim1 = Annotated[ndarray, IsAttr['ndim', IsEqual[1]]]
'''
Expand Down

0 comments on commit a8aea09

Please sign in to comment.