Skip to content

Commit

Permalink
replace List from typing
Browse files Browse the repository at this point in the history
  • Loading branch information
TaiSakuma committed Oct 17, 2023
1 parent 223ffdb commit df266b9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/apluggy/_wrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
import asyncio
import contextlib
from dataclasses import dataclass
from typing import Any, Generator, List, Optional
from typing import Any, Generator, Optional

from exceptiongroup import BaseExceptionGroup
from pluggy import PluginManager as PluginManager_
Expand All @@ -127,7 +127,7 @@ def __init__(self, pm: PluginManager_):

def __getattr__(self, name):
@contextlib.contextmanager
def call(*args, **kwargs) -> Generator[List, Any, List]:
def call(*args, **kwargs) -> Generator[list, Any, list]:
hook = getattr(self.pm.hook, name)
with contextlib.ExitStack() as stack:
hook_impls = hook(*args, **kwargs)
Expand All @@ -148,8 +148,8 @@ def call(*args, **kwargs) -> Generator[List, Any, List]:
return call

def _support_gen(
self, yields: List, hook_impls: List[contextlib._GeneratorContextManager]
) -> Generator[List, Any, List]:
self, yields: list, hook_impls: list[contextlib._GeneratorContextManager]
) -> Generator[list, Any, list]:
'''This generator method
1. supports `send()` through the `gen` attribute
(https://stackoverflow.com/a/68304565/7309855),
Expand All @@ -173,7 +173,7 @@ class _Context:
# gen.throw() has been called.
# Throw the exception to all hook implementations
# that have not exited.
raised: List[BaseException] = []
raised: list[BaseException] = []
for c in contexts:
if c.stop_iteration:
continue
Expand Down
10 changes: 5 additions & 5 deletions tests/test_with_send_throw.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from itertools import zip_longest
from typing import ContextManager, Generator, List, Optional
from typing import ContextManager, Generator, Optional

import pytest
from exceptiongroup import BaseExceptionGroup
Expand Down Expand Up @@ -38,7 +38,7 @@ def __init__(self, thrown: Thrown):

@contextmanager
def context(
yields: List[str], expected_receives: List[str], ret: Optional[str], handle: bool
yields: list[str], expected_receives: list[str], ret: Optional[str], handle: bool
) -> Generator[str, str, Optional[str]]:
'''To be hooked as hook implementation in plugins.'''

Expand Down Expand Up @@ -78,8 +78,8 @@ def context(
class Plugin:
def __init__(
self,
yields: List[str],
expected_receives: List[str],
yields: list[str],
expected_receives: list[str],
ret: Optional[str],
handle: bool,
):
Expand All @@ -101,7 +101,7 @@ def bare(self) -> ContextManager[str]:


def check_context(
yields: List[str], sends: List[str], ret: Optional[str], throw: bool, handle: bool
yields: list[str], sends: list[str], ret: Optional[str], throw: bool, handle: bool
):
'''Test context() by itself without being hooked in a plugin.'''
c = context(yields=yields, expected_receives=sends, ret=ret, handle=handle)
Expand Down

1 comment on commit df266b9

@glensc
Copy link

@glensc glensc commented on df266b9 May 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? And why no Pull Request? Is this the reason python dependency is now 3.10?

Please sign in to comment.