Skip to content

Commit

Permalink
Bump piped from b394fe1 to 9c9ebc5 (#468)
Browse files Browse the repository at this point in the history
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Faster Speeding <[email protected]>
Co-authored-by: always-on-duty[bot] <120557446+always-on-duty[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 27, 2024
1 parent d6de58a commit 3ed7d04
Show file tree
Hide file tree
Showing 36 changed files with 2,194 additions and 1,067 deletions.
2 changes: 1 addition & 1 deletion .github/actions/setup-py/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ runs:
python-version: ${{ inputs.python-version }}

- name: Install Nox
run: pipx install nox --python "${{ steps.install-py.outputs.python-path }}"
run: pipx install uv nox[uv] --python "${{ steps.install-py.outputs.python-path }}"
shell: bash
2 changes: 1 addition & 1 deletion .github/workflows/freeze-for-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
pull_request:
branches:
- master
paths: ["piped", "pyproject.toml", "requirements.in", "dev-requirements/*.in", "!dev-requirements/constraints.in"]
paths: ["piped", "pyproject.toml"]

jobs:
freeze-pr-dep-changes:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ jobs:
- name: Check spelling
run: nox -s spell-check

- name: Lint with flake8
run: nox -s flake8
- name: Lint with Ruff
run: nox -s lint

- name: Check slotting
run: nox -s slot-check
29 changes: 0 additions & 29 deletions .github/workflows/verify-locks.yml

This file was deleted.

1 change: 0 additions & 1 deletion alluka/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# BSD 3-Clause License
#
# Copyright (c) 2020-2024, Faster Speeding
Expand Down
9 changes: 3 additions & 6 deletions alluka/_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# BSD 3-Clause License
#
# Copyright (c) 2020-2024, Faster Speeding
Expand Down Expand Up @@ -80,13 +79,11 @@ def inject(*, callback: alluka.CallbackSig[_T]) -> _T: ...


@typing.overload
def inject(*, type: _TypeT[_T]) -> _T: # noqa: A002
...
def inject(*, type: _TypeT[_T]) -> _T: ...


@typing.overload
def inject(*, type: typing.Any = None) -> typing.Any: # noqa: A002
...
def inject(*, type: typing.Any = None) -> typing.Any: ...


def inject(*, callback: alluka.CallbackSig[_T] | None = None, type: typing.Any = None) -> typing.Any: # noqa: A002
Expand Down Expand Up @@ -270,7 +267,7 @@ async def call_with_ctx_async(
if asyncio.iscoroutine(result):
return typing.cast("_T", await result)

return typing.cast("_T", result) # noqa: ASYNC910 # This is ignored for performance's sake.
return typing.cast("_T", result)

def set_type_dependency(self, type_: type[_T], value: _T, /) -> Self:
# <<inherited docstring from alluka.abc.Client>>.
Expand Down
3 changes: 1 addition & 2 deletions alluka/_context.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# BSD 3-Clause License
#
# Copyright (c) 2020-2024, Faster Speeding
Expand Down Expand Up @@ -90,7 +89,7 @@ def get_type_dependency(self, type_: type[_T], /, *, default: _DefaultT) -> _T |
def get_type_dependency(self, type_: type[_T], /, *, default: _DefaultT | _NoValue = _NO_VALUE) -> _T | _DefaultT:
# <<inherited docstring from alluka.abc.Context>>.
if type_ is alluka.Context:
return self # type: ignore
return self # type: ignore # noqa: PGH003

result = self._client.get_type_dependency(type_, default=default)

Expand Down
1 change: 0 additions & 1 deletion alluka/_errors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# BSD 3-Clause License
#
# Copyright (c) 2020-2024, Faster Speeding
Expand Down
1 change: 0 additions & 1 deletion alluka/_self_injecting.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# BSD 3-Clause License
#
# Copyright (c) 2020-2024, Faster Speeding
Expand Down
28 changes: 13 additions & 15 deletions alluka/_types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# BSD 3-Clause License
#
# Copyright (c) 2020-2024, Faster Speeding
Expand Down Expand Up @@ -73,7 +72,7 @@ def __init__(self, callback: alluka.CallbackSig[typing.Any], /) -> None:
self.callback = callback

def resolve(self, ctx: alluka.Context) -> typing.Any:
"""Synchronously resolve the callback.
"""Resolve the callback synchronously.
!!! warning
Unlike [InjectedCallback.resolve_async][], this method will block the
Expand Down Expand Up @@ -176,9 +175,8 @@ def resolve(self, ctx: alluka.Context) -> typing.Any:
if self.default is not UNDEFINED:
return self.default

raise _errors.MissingDependencyError(
f"Couldn't resolve injected type(s) {self.repr_type} to actual value", self.repr_type
) from None
error_message = f"Couldn't resolve injected type(s) {self.repr_type} to actual value"
raise _errors.MissingDependencyError(error_message, self.repr_type) from None


class InjectedTypes(int, enum.Enum):
Expand All @@ -198,10 +196,10 @@ class InjectedTypes(int, enum.Enum):
"""


InjectedTuple = typing.Union[
tuple[typing.Literal[InjectedTypes.CALLBACK], InjectedCallback],
tuple[typing.Literal[InjectedTypes.TYPE], InjectedType],
]
InjectedTuple = (
tuple[typing.Literal[InjectedTypes.CALLBACK], InjectedCallback]
| tuple[typing.Literal[InjectedTypes.TYPE], InjectedType]
)
"""Type of the tuple used to describe an injected value."""

_TypeT = type[_T]
Expand All @@ -221,7 +219,7 @@ class InjectedDescriptor(typing.Generic[_T]):
If this is `None` then this is a type dependency.
"""

type: _TypeT[_T] | None # noqa: VNE003
type: _TypeT[_T] | None
"""The type to use to resolve the parameter's value.
If both this and `callback` are `None`, then this is a type dependency
Expand Down Expand Up @@ -263,15 +261,15 @@ def __init__(
If both `callback` and `type` are provided.
"""
if callback is not None and type is not None:
raise ValueError("Only one of `callback` or `type` can be specified")
error_message = "Only one of `callback` or `type` can be specified"
raise ValueError(error_message)

self.callback = callback
self.type = type

def __getattr__(self, __name: str) -> typing.NoReturn:
raise AttributeError(
"Tried accessing a parameter that was not injected yet. Did you forget to inject dependencies?"
)
def __getattr__(self, name: str, /) -> typing.NoReturn:
error_message = "Tried accessing a parameter that was not injected yet. Did you forget to inject dependencies?"
raise AttributeError(error_message)


Injected = typing.Annotated[_T, InjectedTypes.TYPE]
Expand Down
11 changes: 6 additions & 5 deletions alluka/_visitor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# BSD 3-Clause License
#
# Copyright (c) 2020-2024, Faster Speeding
Expand Down Expand Up @@ -62,7 +61,7 @@ class Annotation(Node):

__slots__ = ("_callback", "_name", "_raw_annotation")

def __init__(self, callback: Callback, name: str, /):
def __init__(self, callback: Callback, name: str, /) -> None:
self._callback = callback
self._name = name
self._raw_annotation = callback.parameters[name].annotation
Expand Down Expand Up @@ -152,7 +151,7 @@ class ParameterVisitor:

__slots__ = ()

_NODES: list[collections.Callable[[Callback, str], Node]] = [Default, Annotation]
_NODES: tuple[collections.Callable[[Callback, str], Node], ...] = (Default, Annotation)

def _parse_type(
self, type_: typing.Any, *, default: typing.Any | _types.Undefined = _types.UNDEFINED
Expand Down Expand Up @@ -218,7 +217,8 @@ def visit_callback(self, callback: Callback, /) -> dict[str, _types.InjectedTupl
continue

if value.kind is value.POSITIONAL_ONLY:
raise ValueError("Injected positional only arguments are not supported")
error_message = "Injected positional only arguments are not supported"
raise ValueError(error_message)

results[name] = result
break
Expand All @@ -237,6 +237,7 @@ def visit_default(self, value: Default, /) -> _types.InjectedTuple | None:
return self._parse_type(descriptor.type)

if (annotation := value.callback.resolve_annotation(value.name)) is _types.UNDEFINED:
raise ValueError(f"Could not resolve type for parameter {value.name!r} with no annotation")
error_message = f"Could not resolve type for parameter {value.name!r} with no annotation"
raise ValueError(error_message)

return self._annotation_to_type(annotation)
15 changes: 10 additions & 5 deletions alluka/abc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# BSD 3-Clause License
#
# Copyright (c) 2020-2024, Faster Speeding
Expand Down Expand Up @@ -105,7 +104,7 @@ def as_async_self_injecting(
!!! warning "deprecated"
This is deprecated as of `v0.2.0`, use
[Client.auto_inject_async][alluka.abc.Client.auto_inject_async].
"""
""" # noqa: D401

@abc.abstractmethod
@typing_extensions.deprecated("Use .auto_inject")
Expand All @@ -117,7 +116,7 @@ def as_self_injecting(
!!! warning "deprecated"
This is deprecated as of `v0.2.0`, use
[Client.auto_inject][alluka.abc.Client.auto_inject].
"""
""" # noqa: D401

def auto_inject(self, callback: collections.Callable[_P, _T], /) -> collections.Callable[_P, _T]:
"""Wrap a function to make calls to it always inject dependencies.
Expand Down Expand Up @@ -467,7 +466,9 @@ class Context(abc.ABC):
def injection_client(self) -> Client:
"""Injection client this context is bound to."""

def cache_result(self, callback: CallbackSig[_T], value: _T, /) -> None:
def cache_result( # noqa: B027 # Empty method in an abstract base class, but has no abstract decorator
self, callback: CallbackSig[_T], value: _T, /
) -> None:
"""Cache the result of a callback within the scope of this context.
Whether this does anything or is a noop is implementation detail.
Expand Down Expand Up @@ -553,7 +554,11 @@ def get_cached_result(self, callback: CallbackSig[_T], /) -> _T: ...
def get_cached_result(self, callback: CallbackSig[_T], /, *, default: _DefaultT) -> _T | _DefaultT: ...

def get_cached_result(
self, callback: CallbackSig[_T], /, *, default: _DefaultT | _NoValue = _NO_VALUE
self,
callback: CallbackSig[_T], # noqa: ARG002 # Unused method argument:
/,
*,
default: _DefaultT | _NoValue = _NO_VALUE,
) -> _T | _DefaultT:
"""Get the cached result of a callback.
Expand Down
13 changes: 7 additions & 6 deletions alluka/local.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# BSD 3-Clause License
#
# Copyright (c) 2020-2024, Faster Speeding
Expand Down Expand Up @@ -63,7 +62,6 @@
from . import abc

if typing.TYPE_CHECKING:
import typing
from collections import abc as collections

_DefaultT = typing.TypeVar("_DefaultT")
Expand Down Expand Up @@ -113,7 +111,8 @@ def initialize(client: abc.Client | None = None, /) -> abc.Client:
If the local client is already set for the current scope.
"""
if _injector.get(None) is not None:
raise RuntimeError("Alluka client already set for the current scope")
error_message = "Alluka client already set for the current scope"
raise RuntimeError(error_message)

client = client or _client.Client()
_injector.set(client)
Expand Down Expand Up @@ -259,7 +258,8 @@ def get_client(*, default: _DefaultT | _NoValue = _NO_VALUE) -> abc.Client | _De
client = _injector.get(None)
if client is None:
if default is _NO_VALUE:
raise RuntimeError("No Alluka client set for the current scope")
error_message = "No Alluka client set for the current scope"
raise RuntimeError(error_message)

return default

Expand All @@ -278,7 +278,7 @@ def get(*, default: _DefaultT) -> abc.Client | _DefaultT: ...

@typing_extensions.deprecated("Use get_client or get_context")
def get(*, default: _DefaultT | _NoValue = _NO_VALUE) -> abc.Client | _DefaultT:
"""Deprecated alias of [get_client][alluka.local.get_client]."""
"""Deprecated alias of [get_client][alluka.local.get_client].""" # noqa: D401
if default is _NO_VALUE:
return get_client()

Expand Down Expand Up @@ -330,7 +330,8 @@ def get_context(*, default: _DefaultT | _NoValue = _NO_VALUE, from_client: bool
pass

if default is _NO_VALUE:
raise RuntimeError("Alluka context not set for the current scope")
error_message = "Alluka context not set for the current scope"
raise RuntimeError(error_message)

return default

Expand Down
1 change: 0 additions & 1 deletion dev-requirements/constraints.in

This file was deleted.

9 changes: 0 additions & 9 deletions dev-requirements/constraints.txt

This file was deleted.

1 change: 0 additions & 1 deletion dev-requirements/flake8.txt

This file was deleted.

9 changes: 0 additions & 9 deletions dev-requirements/tests.in

This file was deleted.

Loading

0 comments on commit 3ed7d04

Please sign in to comment.