Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump piped from 7f3b3fa to b4b1a5d #415

Merged
merged 29 commits into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
d00000e
Bump piped from `7f3b3fa` to `b4b1a5d`
dependabot[bot] Aug 11, 2024
6fb6d8b
Resync piped
always-on-duty[bot] Aug 11, 2024
669a457
Freeze PR dependency changes
always-on-duty[bot] Aug 11, 2024
61fbed7
Update _client.py
FasterSpeeding Aug 11, 2024
b95e3cd
Update test_async_callback_di.py
FasterSpeeding Aug 11, 2024
ae417da
Reformat PR code
always-on-duty[bot] Aug 11, 2024
b79cf5c
Update test_async_callback_di_future_annotations.py
FasterSpeeding Aug 11, 2024
be99ac4
Reformat PR code
always-on-duty[bot] Aug 11, 2024
8c800d5
Update test_callback_di.py
FasterSpeeding Aug 11, 2024
daa4748
Reformat PR code
always-on-duty[bot] Aug 11, 2024
e25afeb
Update test_callback_di_future_annotations.py
FasterSpeeding Aug 11, 2024
794d49f
Reformat PR code
always-on-duty[bot] Aug 11, 2024
f5d4b6a
Update test_async_callback_di.py
FasterSpeeding Aug 11, 2024
6b83c5b
Update test_async_callback_di.py
FasterSpeeding Aug 11, 2024
91d459f
Update test_async_callback_di_future_annotations.py
FasterSpeeding Aug 11, 2024
83a6610
Update test_callback_di.py
FasterSpeeding Aug 11, 2024
764659d
Update test_callback_di_future_annotations.py
FasterSpeeding Aug 11, 2024
caf7722
Update test_async_callback_di.py
FasterSpeeding Aug 11, 2024
822597d
Reformat PR code
always-on-duty[bot] Aug 11, 2024
610d9e6
Update test_async_callback_di.py
FasterSpeeding Aug 11, 2024
50431b1
Reformat PR code
always-on-duty[bot] Aug 11, 2024
697c19a
Update test_async_callback_di_future_annotations.py
FasterSpeeding Aug 11, 2024
a67364a
Reformat PR code
always-on-duty[bot] Aug 11, 2024
1e4d16f
Update test_callback_di.py
FasterSpeeding Aug 11, 2024
e6017f7
Reformat PR code
always-on-duty[bot] Aug 11, 2024
a434af5
Update test_callback_di_future_annotations.py
FasterSpeeding Aug 11, 2024
8526c30
Reformat PR code
always-on-duty[bot] Aug 11, 2024
00b777f
Update test_async_callback_di.py
FasterSpeeding Aug 11, 2024
462a265
Reformat PR code
always-on-duty[bot] Aug 11, 2024
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 .github/workflows/freeze-for-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Upgrade dependency locks
run: python -m nox -s freeze-locks bot-package-diff

- uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b
- uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a
with:
name: gogo.patch
path: gogo.patch
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/py-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
coverageLocations: .coverage.xml:coverage.py

- name: Archive coverage
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a
with:
name: coverage
path: ./coverage_html
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reformat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Reformat
run: python -m nox -s reformat bot-package-diff

- uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b
- uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a
with:
name: gogo.patch
path: gogo.patch
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/resync-piped.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Resync Piped
run: python -m nox -s copy-piped bot-package-diff

- uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b
- uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a
with:
name: gogo.patch
path: gogo.patch
Expand Down
2 changes: 1 addition & 1 deletion alluka/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def __init__(self, *, introspect_annotations: bool = True) -> None:
] = weakref.WeakKeyDictionary()
self._introspect_annotations = introspect_annotations
static_context = _context.Context(self)
self._make_context: collections.Callable[[Self], alluka.Context] = lambda _: static_context # pyright: ignore
self._make_context: collections.Callable[[Self], alluka.Context] = lambda _: static_context
self._type_dependencies: dict[type[typing.Any], typing.Any] = {alluka.Client: self, Client: self}

def _build_descriptors(self, callback: alluka.CallbackSig[typing.Any], /) -> dict[str, _types.InjectedTuple]:
Expand Down
259 changes: 147 additions & 112 deletions dev-requirements/tests.txt

Large diffs are not rendered by default.

327 changes: 181 additions & 146 deletions dev-requirements/type-checking.txt

Large diffs are not rendered by default.

61 changes: 41 additions & 20 deletions tests/test_async_callback_di.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ async def dependency(
async def callback(
value_1: int,
value_2: str,
value_3: alluka.Injected[str] = alluka.inject(type=MockType),
value_3: alluka.Injected[str] = alluka.inject(type=MockType), # type: ignore
value_4: typing.Annotated[int, alluka.inject(type=float)] = alluka.inject(type=MockOtherType),
value_5: typing.Annotated[str, alluka.inject(callback=mock.Mock)] = alluka.inject(callback=dependency),
) -> str:
Expand Down Expand Up @@ -133,8 +133,8 @@ async def test_call_with_async_di_with_type_dependency_and_callback(context: all
async def callback(
value_1: int,
value_2: str,
value_3: str = alluka.inject(type=MockType),
value_4: int = alluka.inject(type=MockOtherType),
value_3: MockType = alluka.inject(type=MockType),
value_4: MockOtherType = alluka.inject(type=MockOtherType),
value_5: typing.Any = alluka.inject(callback=mock_callback),
) -> str:
assert value_1 == 69
Expand All @@ -160,8 +160,8 @@ async def test_call_with_async_di_with_type_dependency(context: alluka.Context):
async def callback(
value_1: int,
value_2: str,
value_3: str = alluka.inject(type=MockType),
value_4: int = alluka.inject(type=MockOtherType),
value_3: MockType = alluka.inject(type=MockType),
value_4: MockOtherType = alluka.inject(type=MockOtherType),
) -> str:
assert value_1 == 69
assert value_2 == "rew"
Expand Down Expand Up @@ -235,7 +235,10 @@ async def test_call_with_async_di_with_type_dependency_not_found(context: alluka
value = mock.Mock()

async def callback(
_: int, value: str, __: str = alluka.inject(type=MockType), ___: int = alluka.inject(type=MockOtherType)
_: int,
value: str,
__: MockType = alluka.inject(type=MockType),
___: MockOtherType = alluka.inject(type=MockOtherType),
) -> str:
raise NotImplementedError

Expand All @@ -253,7 +256,7 @@ async def test_call_with_async_di_with_defaulting_type_dependency(context: alluk
value = mock.Mock()

async def callback(
value_1: int, value_2: str, value_3: typing.Optional[int] = alluka.inject(type=typing.Optional[MockType])
value_1: int, value_2: str, value_3: typing.Optional[MockType] = alluka.inject(type=typing.Optional[MockType])
) -> str:
assert value_1 == 69
assert value_2 == "rew"
Expand All @@ -270,7 +273,7 @@ async def callback(
@pytest.mark.anyio
async def test_call_with_async_di_with_defaulting_type_dependency_not_found(context: alluka.Context):
async def callback(
yeet: int, raw: str, value_1: typing.Optional[int] = alluka.inject(type=typing.Optional[MockType])
yeet: int, raw: str, value_1: typing.Optional[MockType] = alluka.inject(type=typing.Optional[MockType])
) -> str:
assert yeet == 420
assert raw == "uwu"
Expand All @@ -292,7 +295,7 @@ async def test_call_with_async_di_with_3_10_union_type_dependency(context: alluk
context.injection_client.set_type_dependency(MockType, value)

async def callback(
value_1: int, value_2: str, cope: int = alluka.inject(type=MockOtherType | MockType)
value_1: int, value_2: str, cope: MockOtherType | MockType = alluka.inject(type=MockOtherType | MockType)
) -> float:
assert value_1 == 123
assert value_2 == "ok"
Expand All @@ -305,7 +308,9 @@ async def callback(

@pytest.mark.anyio
async def test_call_with_async_di_with_3_10_union_type_dependency_not_found(context: alluka.Context):
async def callback(_: int, __: str, cope: int = alluka.inject(type=MockOtherType | MockType)) -> float:
async def callback(
_: int, __: str, cope: MockOtherType | MockType = alluka.inject(type=MockOtherType | MockType)
) -> float:
raise NotImplementedError

with pytest.raises(alluka.MissingDependencyError) as exc_info:
Expand All @@ -321,7 +326,9 @@ async def test_call_with_async_di_with_3_10_union_type_dependency_defaulting(con
context.injection_client.set_type_dependency(MockType, value)

async def callback(
value_1: int, value_2: str, cope: int = alluka.inject(type=MockOtherType | MockType | None)
value_1: int,
value_2: str,
cope: MockOtherType | MockType | None = alluka.inject(type=MockOtherType | MockType | None),
) -> float:
assert value_1 == 123
assert value_2 == "ok"
Expand All @@ -335,7 +342,9 @@ async def callback(
@pytest.mark.anyio
async def test_call_with_async_di_with_3_10_union_type_dependency_defaulting_not_found(context: alluka.Context):
async def callback(
value_1: int, value_2: str, cope: int = alluka.inject(type=MockOtherType | MockType | None)
value_1: int,
value_2: str,
cope: MockOtherType | MockType | None = alluka.inject(type=MockOtherType | MockType | None),
) -> float:
assert value_1 == 123
assert value_2 == "ok"
Expand All @@ -353,7 +362,9 @@ async def test_call_with_async_di_with_union_type_dependency(context: alluka.Con
context.injection_client.set_type_dependency(MockOtherType, value)

async def callback(
value_1: int, value_2: str, cope: int = alluka.inject(type=typing.Union[MockType, MockOtherType])
value_1: int,
value_2: str,
cope: typing.Union[MockType, MockOtherType] = alluka.inject(type=typing.Union[MockType, MockOtherType]),
) -> float:
assert value_1 == 123
assert value_2 == "ok"
Expand All @@ -367,7 +378,11 @@ async def callback(

@pytest.mark.anyio
async def test_call_with_async_di_with_union_type_dependency_not_found(context: alluka.Context):
async def callback(_: int, __: str, cope: int = alluka.inject(type=typing.Union[MockType, MockOtherType])) -> float:
async def callback(
_: int,
__: str,
cope: typing.Union[MockType, MockOtherType] = alluka.inject(type=typing.Union[MockType, MockOtherType]),
) -> float:
raise NotImplementedError

with pytest.raises(alluka.MissingDependencyError) as exc_info:
Expand All @@ -385,7 +400,11 @@ async def test_call_with_async_di_with_defaulting_union_type_dependency(context:
context.injection_client.set_type_dependency(MockOtherType, value)

async def callback(
value_1: int, value_2: str, cope: int = alluka.inject(type=typing.Union[MockType, MockOtherType, None])
value_1: int,
value_2: str,
cope: typing.Union[MockType, MockOtherType, None] = alluka.inject(
type=typing.Union[MockType, MockOtherType, None]
),
) -> float:
assert value_1 == 123
assert value_2 == "ok"
Expand All @@ -400,7 +419,7 @@ async def callback(
@pytest.mark.anyio
async def test_call_with_async_di_with_defaulting_union_type_dependency_not_found(context: alluka.Context):
async def callback(
value_1: float, value_2: int, cope: typing.Optional[int] = alluka.inject(type=typing.Optional[MockType])
value_1: float, value_2: int, cope: typing.Optional[MockType] = alluka.inject(type=typing.Optional[MockType])
) -> float:
assert value_1 == 123.321
assert value_2 == 543
Expand Down Expand Up @@ -1123,7 +1142,7 @@ async def test_call_with_async_di_with_sub_type_dependency(context: alluka.Conte
value = mock.Mock()
context.injection_client.set_type_dependency(MockType, value)

async def dependency(result: int = alluka.inject(type=MockType)) -> int:
async def dependency(result: MockType = alluka.inject(type=MockType)) -> int:
assert result is value
return 123321

Expand All @@ -1139,7 +1158,7 @@ async def callback(value_1: int, result: int = alluka.inject(callback=dependency

@pytest.mark.anyio
async def test_call_with_async_di_with_sub_type_dependency_not_found(context: alluka.Context):
async def dependency(result: int = alluka.inject(type=MockType)) -> int:
async def dependency(result: MockType = alluka.inject(type=MockType)) -> int:
raise NotImplementedError

async def callback(_: int, result: int = alluka.inject(callback=dependency)) -> str:
Expand Down Expand Up @@ -1357,7 +1376,9 @@ async def callback(

@pytest.mark.anyio
async def test_call_with_async_di_with_positional_only_type_dependency(context: alluka.Context):
async def callback(_: int, __: str = alluka.inject(type=float), /, ___: float = alluka.inject(type=float)) -> None:
async def callback(
_: int, __: float = alluka.inject(type=float), /, ___: float = alluka.inject(type=float)
) -> None:
raise NotImplementedError

with pytest.raises(ValueError, match="Injected positional only arguments are not supported"):
Expand Down Expand Up @@ -1395,7 +1416,7 @@ async def callback(

@pytest.mark.anyio
async def test_call_with_async_di_with_sub_positional_only_type_dependency(context: alluka.Context):
async def dependency(_: str = alluka.inject(type=int), /) -> str:
async def dependency(_: int = alluka.inject(type=int), /) -> str:
raise NotImplementedError

async def callback(
Expand Down
Loading
Loading