Skip to content

Commit

Permalink
move this over
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeshardmind committed Apr 3, 2024
1 parent 7ffba71 commit 0d14d42
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 28 deletions.
2 changes: 1 addition & 1 deletion umn_async_utils/__init__.py → async_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# limitations under the License.


__version__ = "3.0.0"
__version__ = "4.0.0"
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
# It's included in minimal, simplified form based on specific use


class _HashedSeq(list):
class _HashedSeq(list):
""" This class guarantees that hash() will be called no more than once
per element. This is important because the lru_cache() will hash
the key multiple times on a cache miss.
"""

__slots__ = 'hashvalue'
__slots__ = ('hashvalue',)

def __init__(self, tup, hash=hash):
self[:] = tup
Expand Down
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions umn_async_utils/scheduler.py → async_utils/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
T = TypeVar("T")


class CancelationToken(object):
class CancelationToken:
__slots__ = ()


Expand Down Expand Up @@ -110,9 +110,10 @@ async def cancel_task(self, cancel_token: CancelationToken, /) -> bool:
try:
task = self.__tasks[cancel_token]
task.canceled = True
return True
except KeyError:
pass
else:
return True
return False

def close(self):
Expand Down
File renamed without changes.
6 changes: 2 additions & 4 deletions umn_async_utils/waterfall.py → async_utils/waterfall.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@

import asyncio
import time
from collections.abc import Callable, Coroutine, Sequence
from typing import (
Any,
Callable,
Coroutine,
Generic,
Literal,
Sequence,
TypeVar,
overload,
overload
)

T = TypeVar("T")
Expand Down
50 changes: 37 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,8 @@
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[tool.black]
line-length = 88
target-version = ["py37"]
include = '\.py$'

[tool.isort]
profile = "black"
combine_as_imports = true
combine_star = true
line_length = 88

[tool.pyright]
include = ["umn_async_utils"]
include = ["async_utils"]
exclude = [
"**/__pycache__",
"build",
Expand All @@ -27,4 +16,39 @@ typeCheckingMode = "strict"
pythonPlatform = "All"
reportMissingImports = true
reportMissingTypeStubs = false
reportUnnecessaryTypeIgnoreComment = true
reportUnnecessaryTypeIgnoreComment = true


[tool.ruff]

line-length = 130
target-version = "py310"
select = [
"F", "E", "I", "UP", "YTT", "ANN", "S", "BLE", "B", "A", "COM", "C4", "DTZ",
"EM", "ISC", "G", "INP", "PIE", "T20", "Q003", "RSE", "RET", "SIM", "TID", "PTH",
"ERA", "PD", "PLC", "PLE", "PLW", "TRY", "NPY", "RUF"
]

extend-ignore = [
"G002", # erroneous issue with %-logging when logging can be confiured for % logging
"S101", # use of assert here is a known quantity, blame typing memes
"PLR2004", # Magic value comparison, may remove later
"SIM105", # supressable exception, I'm not paying the overhead of contextlib.supress for stylistic choices.
"C90", # mccabe complexity memes
"ANN101", # missing "Self" annotation, self is implicit
"ANN102", # Same, but for cls
"ANN201", # return types
"ANN204", # special method return types
"PLR0913", # number of function arguments
"UP007", # "Use | For Union" doesn't account for typevar tuple unpacking.
"PTH123", # `open()` should be replaced by `Path.open()`
"PLR", # more complexity things
"COM812", # trailing commmas
"ERA001", # commented out code
"E731", # No, I think I'll keep my lambdas when I feel they are the right call
"B905", # zip without explicit strict=
"COM819", # reccomended by ruff when using ruff format
"E501", # reccomended by ruff when using ruff format
"ISC001", # reccomended by ruff when using ruff format
"Q003", # reccomended by ruff when using ruff format
]
14 changes: 8 additions & 6 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
[metadata]
name = umn-async-utils
name = async-utils
version = attr: umn_async_utils.__version__
description = Various async utilities
license = Apache-2.0
long_description = file: README.md
long_description_content_type = text/markdown; charset=UTF-8; variant=GFM
author = Michael Hall

url = https://github.com/unified-moderation-network/umn-async-utils
url = https://github.com/mikeshardmind/async-utils
project_urls =
Issue Tracker = https://github.com/unified-moderation-network/umn-async-utils/issues
Source Code = https://github.com/unified-moderation-network/umn-async-utils
Issue Tracker = https://github.com/mikeshardmind/async-utils/issues
Source Code = https://github.com/mikeshardmind/async-utils
classifiers =
Framework :: AsyncIO
Intended Audience :: Developers
Natural Language :: English
Typing :: Typed
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
license_files =
LICENSE
NOTICE
Expand All @@ -33,5 +35,5 @@ umn-async-utils = py.typed

[options.packages.find]
include =
umn_async_utils
umn_async_utils.*
async_utils
async_utils.*

0 comments on commit 0d14d42

Please sign in to comment.