Skip to content

Commit

Permalink
Merge pull request #135 from MatterMiners/maintenance/checks20240202
Browse files Browse the repository at this point in the history
Inspection maintenance
  • Loading branch information
maxfischer2781 authored Feb 14, 2024
2 parents ff1d810 + 13adaf9 commit 89860d3
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[flake8]
statistics = True
max-line-length = 80
ignore = E501, B008, B011, W503, B905
select = C,E,F,W,B,B9
ignore = E203, E501, E704, B008, B011, B905, W503
exclude = docs,.svn,CVS,.bzr,.hg,.git,__pycache__,.tox,.eggs,*.egg
8 changes: 4 additions & 4 deletions cobald_tests/controller/test_stepwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ class TestStepwise:
def test_add(self):
@stepwise
def control(pool, interval):
...
pass

assert isinstance(control, UnboundStepwise)

@control.add(supply=20)
def rule(pool, interval):
...
pass

assert isinstance(control, UnboundStepwise)
assert isinstance(rule, FunctionType)

def test_instantiate(self):
@stepwise
def control(pool, interval):
...
pass

assert isinstance(control(FullMockPool()), Stepwise)
assert isinstance(control.s() >> FullMockPool(), Stepwise)
Expand All @@ -32,7 +32,7 @@ def control(pool, interval):

@control.add(supply=20)
def rule(pool, interval):
...
pass

assert isinstance(control(FullMockPool()), Stepwise)
assert isinstance(control.s() >> FullMockPool(), Stepwise)
Expand Down
8 changes: 5 additions & 3 deletions cobald_tests/decorator/test_logger.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import threading
import logging
import io
import warnings

import pytest

Expand Down Expand Up @@ -56,10 +57,11 @@ def test_name(self):

def test_verification(self):
pool = FullMockPool()
# no warnings by default
with pytest.warns(None) as recorded_warnings:
# ensure no warnings by default
# see https://docs.pytest.org/en/8.0.x/how-to/capture-warnings.html#additional-use-cases-of-warnings-in-tests # noqa
with warnings.catch_warnings():
warnings.simplefilter("error")
Logger(target=pool, name="test logger")
assert not recorded_warnings

pool = FullMockPool()
with pytest.warns(FutureWarning):
Expand Down
4 changes: 2 additions & 2 deletions cobald_tests/interfaces/test_partial.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

class MockController(Controller):
def regulate(self, interval: float):
...
pass


class MockDecorator(PoolDecorator):
...
pass


class TestPartial(object):
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
python_requires=">=3.8",
install_requires=[
"pyyaml",
"trio>=0.4.0",
"trio",
"entrypoints",
"toposort",
],
Expand All @@ -68,6 +68,7 @@
"flake8",
"flake8-bugbear",
"black; implementation_name=='cpython'",
"pytest>=8.0",
"pytest-cov",
]
+ TESTS_REQUIRE,
Expand Down
1 change: 1 addition & 0 deletions src/cobald/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
This is a **draft** for a feedback based balancing system for providing
opportunistic resources.
"""

__title__ = "cobald"
__summary__ = "COBalD - the Opportunistic Balancing Daemon"
__url__ = "https://github.com/MatterMiners/cobald"
Expand Down
8 changes: 4 additions & 4 deletions src/cobald/controller/stepwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ def __init__(self, base: ControlRule):
self._thresholds: Set[float] = set()

@overload # noqa: F811
def add(self, rule: ControlRule, *, supply: float) -> ControlRule:
...
def add(self, rule: ControlRule, *, supply: float) -> ControlRule: ...

@overload # noqa: F811
def add(self, rule: None, *, supply: float) -> Callable[[ControlRule], ControlRule]:
...
def add(
self, rule: None, *, supply: float
) -> Callable[[ControlRule], ControlRule]: ...

def add(self, rule: ControlRule = None, *, supply: float): # noqa: F811
"""
Expand Down
8 changes: 5 additions & 3 deletions src/cobald/daemon/core/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ def initialise_logging(level: str, target: str, short_format: bool):
handler = create_handler(target=target)
logging.basicConfig(
level=log_level,
format="%(asctime)-15s (%(process)d) %(message)s"
if not short_format
else "%(message)s",
format=(
"%(asctime)-15s (%(process)d) %(message)s"
if not short_format
else "%(message)s"
),
datefmt="%Y-%m-%d %H:%M:%S",
handlers=[handler],
)
1 change: 1 addition & 0 deletions src/cobald/daemon/core/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Daemon core specific to cobald
"""

import asyncio
import sys
import logging
Expand Down
8 changes: 5 additions & 3 deletions src/cobald/daemon/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ def pretty_partial(obj: partial) -> str:
return "partial(%s%s%s)" % (
pretty_ref(obj.func),
"" if not obj.args else ", ".join(repr(arg) for arg in obj.args),
""
if not obj.keywords
else ", ".join("%r = %r" % (k, v) for k, v in obj.keywords.items()),
(
""
if not obj.keywords
else ", ".join("%r = %r" % (k, v) for k, v in obj.keywords.items())
),
)


Expand Down
1 change: 1 addition & 0 deletions src/cobald/daemon/plugins.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Tools and helpers to declare plugins
"""

from typing import Iterable, FrozenSet, TypeVar, NamedTuple


Expand Down
1 change: 1 addition & 0 deletions src/cobald/interfaces/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
}
"""

from ._composite import CompositePool
from ._controller import Controller
from ._pool import Pool
Expand Down
16 changes: 8 additions & 8 deletions src/cobald/interfaces/_partial.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class Partial(Generic[C_co]):
creates a temporary :py:class:`~.PartialBind`. Only binding to a
:py:class:`~.Pool` as the last element creates a concrete binding.
"""

__slots__ = ("ctor", "args", "kwargs", "leaf")

def __init__(self, ctor: Type[C_co], *args, __leaf__, **kwargs):
Expand Down Expand Up @@ -74,12 +75,12 @@ def __construct__(self, *args, **kwargs):
return self.ctor(*args, *self.args, **kwargs, **self.kwargs)

@overload # noqa: F811
def __rshift__(self, other: "Union[Owner, Pool, PartialBind[Pool]]") -> "C_co":
...
def __rshift__(self, other: "Union[Owner, Pool, PartialBind[Pool]]") -> "C_co": ...

@overload # noqa: F811
def __rshift__(self, other: "Union[Partial, PartialBind]") -> "PartialBind[C_co]":
...
def __rshift__(
self, other: "Union[Partial, PartialBind]"
) -> "PartialBind[C_co]": ...

def __rshift__(self, other): # noqa: F811
if isinstance(other, PartialBind):
Expand Down Expand Up @@ -107,6 +108,7 @@ class PartialBind(Generic[C_co]):
This helper is used to invert the operator precedence of ``>>``,
allowing the last pair to be bound first.
"""

__slots__ = ("parent", "targets")

def __init__(
Expand All @@ -118,12 +120,10 @@ def __init__(
self.targets = targets

@overload # noqa: F811
def __rshift__(self, other: Partial[Owner]) -> "PartialBind[C_co]":
...
def __rshift__(self, other: Partial[Owner]) -> "PartialBind[C_co]": ...

@overload # noqa: F811
def __rshift__(self, other: "Pool") -> "C_co":
...
def __rshift__(self, other: "Pool") -> "C_co": ...

def __rshift__(self, other: "Union[Pool, Partial[Owner]]"): # noqa: F811
if isinstance(other, _pool.Pool):
Expand Down

0 comments on commit 89860d3

Please sign in to comment.