-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Callan Gray <[email protected]>
- Loading branch information
Showing
8 changed files
with
281 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,8 @@ build-backend = "poetry.core.masonry.api" | |
[tool.poetry] | ||
name = "athreading" | ||
version = "0.1.2" | ||
description = "" | ||
description = "Asynchronous threading package for Python" | ||
readme = "README.md" | ||
authors = ["Callan Gray <[email protected]>"] | ||
license = "BSD-3-Clause" | ||
packages = [{ include = "athreading", from = "src" }] | ||
|
@@ -15,19 +16,20 @@ python = "^3.9" | |
|
||
[tool.poetry.group.test.dependencies] | ||
pytest = ">=7,<9" | ||
pytest-cov = "^4.0.0" | ||
pytest-cov = ">=4,<7" | ||
pytest-mypy = "^0.10.0" | ||
pytest-mock = "^3.7.0" | ||
pytest-asyncio = "^0.20.3" | ||
pytest-benchmark = "^4.0.0" | ||
pytest-mock = "^3.14.0" | ||
pytest-asyncio = ">=0.20.3,<0.26.0" | ||
pytest-benchmark = "^5.1.0" | ||
isort = "^5.10.1" | ||
pre-commit = "^3.0.4" | ||
pre-commit = ">=3.0.4,<5.0.0" | ||
black = ">=23.1,<25.0" | ||
flake8 = ">=6,<8" | ||
flake8-docstrings = "^1.6.0" | ||
flake8-pyproject = "^1.2.2" | ||
aiostream = ">=0.4.5,<0.6.0" | ||
aiostream = ">=0.4.5,<0.7.0" | ||
threaded = "^4.2.0" | ||
typing_extensions = { python = "3.13", version = ">4.12.0" } | ||
|
||
[tool.mypy] | ||
disallow_any_explicit = true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from contextlib import AbstractAsyncContextManager, AbstractContextManager | ||
from typing import TypeVar | ||
|
||
T = TypeVar("T") | ||
|
||
|
||
class nullcontext(AbstractContextManager[T], AbstractAsyncContextManager[T]): | ||
"""Context manager that does no additional processing. | ||
Used as a stand-in for a normal context manager, when a particular | ||
block of code is only sometimes used with a normal context manager: | ||
cm = optional_cm if condition else nullcontext() | ||
with cm: | ||
# Perform operation, using optional_cm if condition is True | ||
""" | ||
|
||
def __init__(self, enter_result=None): | ||
self.enter_result = enter_result | ||
|
||
def __enter__(self): | ||
return self.enter_result | ||
|
||
def __exit__(self, *excinfo): | ||
pass | ||
|
||
async def __aenter__(self): | ||
return self.enter_result | ||
|
||
async def __aexit__(self, *excinfo): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters