Skip to content

Commit

Permalink
chore: refactor (#34)
Browse files Browse the repository at this point in the history
* chore: refactor

* fix(test): fix test semaphore on slow gh runners
  • Loading branch information
BobTheBuidler authored Mar 20, 2023
1 parent 5362bd5 commit f1dd378
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion a_sync/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from a_sync import aliases
from a_sync.base import ASyncGenericBase
from a_sync.decorator import a_sync
from a_sync.semaphores import (DummySemaphore, ThreadsafeSemaphore,
from a_sync.modifiers.semaphores import (DummySemaphore, ThreadsafeSemaphore,
apply_semaphore)
from a_sync.singleton import ASyncGenericSingleton

Expand Down
2 changes: 1 addition & 1 deletion a_sync/aliases.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

from a_sync.modifiers.semaphores import dummy_semaphore as dummy
from a_sync.property import a_sync_cached_property as cached_property
from a_sync.property import a_sync_property as property
from a_sync.semaphores import dummy_semaphore as dummy
2 changes: 1 addition & 1 deletion a_sync/modified.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from a_sync import _helpers, _kwargs, exceptions
from a_sync._typing import *
from a_sync.modifiers import ModifierManager
from a_sync.modifiers.manager import ModifierManager


class Modified(Generic[T]):
Expand Down
4 changes: 2 additions & 2 deletions a_sync/modifiers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from aiolimiter import AsyncLimiter

from a_sync._typing import *
from a_sync.modifiers.manager import ModifierManager, valid_modifiers
from a_sync.semaphores import ThreadsafeSemaphore
from a_sync.modifiers.manager import valid_modifiers
from a_sync.modifiers.semaphores import ThreadsafeSemaphore


def get_modifiers_from(thing: Union[dict, type, object]) -> ModifierKwargs:
Expand Down
3 changes: 1 addition & 2 deletions a_sync/modifiers/manager.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@

import functools

from a_sync import semaphores
from a_sync._typing import *
from a_sync.config import user_set_default_modifiers, null_modifiers
from a_sync.modifiers import cache, limiter
from a_sync.modifiers import cache, limiter, semaphores

valid_modifiers = [key for key in ModifierKwargs.__annotations__ if not key.startswith('_') and not key.endswith('_')]

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion a_sync/property.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from a_sync import config
from a_sync._typing import *
from a_sync.modified import Modified
from a_sync.modifiers import ModifierManager
from a_sync.modifiers.manager import ModifierManager


class PropertyDescriptor(Modified[T]):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_semaphore.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ async def test_semaphore_cached_property(i: int):
# There is a 1 second sleep in this fn but a semaphore override with a value of 50.
# You can tell it worked correctly because the class-defined semaphore value is just one, whch would cause this test to fail if it were used.
# If the override is not working, all tests will complete in just over 1 second.
assert i == 1 or duration < 1.05
assert i == 1 or duration < 1.4 # We increased the threshold from 1.05 to 1.4 to help tests pass on slow github runners

0 comments on commit f1dd378

Please sign in to comment.