Skip to content

Commit

Permalink
fix: Python 3.9, 3.10, 3.11
Browse files Browse the repository at this point in the history
* feat: test multiple py versions in gh actions

* Delete pytest3.9.yaml

* chore: remove unused caches

* feat: allow all runs to finish

* fix: python 3.9

* fix: default mode

* fix: py 3.10
  • Loading branch information
BobTheBuidler authored Mar 18, 2023
1 parent a450ccd commit aef3b92
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 130 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: PyTest

on:
push:
branch: dev
paths:
- '**.py'
- '**/pytest.yaml'
pull_request:
# The branches below must be a subset of the branches above
branches: [ master, dev ]
paths:
- '**.py'
- '**/pytest.yaml'

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
pyversion: [ "3.8", "3.9", "3.10", "3.11" ]

steps:
- name: Check out repository code
uses: actions/checkout@v2

- name: Setup Python (faster than using Python container)
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.pyversion }}

- name: Install dependencies
run: |
pip install pytest
pip install -r requirements.txt
pip install -r requirements-dev.txt
- name: Run test suite
run: pytest

63 changes: 0 additions & 63 deletions .github/workflows/pytest3.8.yaml

This file was deleted.

63 changes: 0 additions & 63 deletions .github/workflows/pytest3.9.yaml

This file was deleted.

3 changes: 1 addition & 2 deletions a_sync/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __a_sync_instance_will_be_sync__(cls, kwargs: dict) -> bool:
try:
return _kwargs.is_sync(kwargs)
except exceptions.NoFlagsFound:
return cls.__a_sync_default_mode__ # type: ignore [return-value]
return cls.__a_sync_default_mode__() # type: ignore [return-value]

######################################
# Concrete Methods (non-overridable) #
Expand All @@ -61,6 +61,5 @@ def __a_sync_flag_value__(self) -> bool:
pass

@abc.abstractclassmethod # type: ignore [misc]
@abc.abstractproperty
def __a_sync_default_mode__(cls) -> bool:
...
3 changes: 2 additions & 1 deletion a_sync/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def __a_sync_flag_value__(self) -> bool:
return flag_value

@classmethod # type: ignore [misc]
@property
def __a_sync_default_mode__(cls) -> bool:
flag = cls.__get_a_sync_flag_name_from_signature()
flag_value = cls.__a_sync_flag_default_value_from_signature
Expand All @@ -46,6 +45,8 @@ def __a_sync_default_mode__(cls) -> bool:
@classmethod
#@property # TODO debug why making this into a classproperty breaks it
def __get_a_sync_flag_name_from_signature(cls) -> str:
if cls.__name__ == "ASyncGenericBase":
return None
signature = inspect.signature(cls.__init__)
present_flags = [flag for flag in _flags.VIABLE_FLAGS if flag in signature.parameters]
if len(present_flags) == 0:
Expand Down
8 changes: 7 additions & 1 deletion a_sync/modified.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import functools
import sys

from a_sync import _helpers, _kwargs, exceptions
from a_sync._typing import *
Expand Down Expand Up @@ -91,8 +92,13 @@ def sync_wrap(*args: P.args, **kwargs: P.kwargs) -> MaybeAwaitable[T]: # type:
return self._modified_fn(*args, **kwargs)
return self._asyncified(*args, **kwargs)
return sync_wrap

if sys.version_info < (3, 10):
_inherit = ASyncFunction[AnyFn[P, T], ASyncFunction[P, T]]
else:
_inherit = ASyncFunction[[AnyFn[P, T]], ASyncFunction[P, T]]

class ASyncDecorator(ASyncFunction[AnyFn[P, T], ASyncFunction[P, T]]):
class ASyncDecorator(_inherit):
_fn = None
def __init__(self, **modifiers: Unpack[ModifierKwargs]) -> None:
assert 'default' in modifiers, modifiers
Expand Down

0 comments on commit aef3b92

Please sign in to comment.