Skip to content

Commit

Permalink
Switched from flake8 to ruff.
Browse files Browse the repository at this point in the history
Python 3.12 tested.
  • Loading branch information
coady committed Mar 21, 2023
1 parent 59e06db commit d3560af
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12.0-alpha - 3.12']
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
Expand All @@ -29,7 +29,7 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: 3.x
- run: pip install black[jupyter] flake8 mypy
- run: pip install black[jupyter] ruff mypy
- run: make lint

docs:
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
check:
pytest -s --cov
python -m pytest -s --cov

lint:
python3 -m black --check .
flake8 --ignore E501,F811,W503
black --check .
ruff .
mypy -p multimethod
mypy tests/static.py | grep -qv Any

html:
PYTHONPATH=$(PWD) python3 -m mkdocs build
PYTHONPATH=$(PWD) python -m mkdocs build
2 changes: 1 addition & 1 deletion multimethod/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def get_type(self, arg) -> type:
tps = {tp for tp, tp_arg in zip(tps, self.__args__) if issubclass(tp, tp_arg)}
if not tps:
return type(arg)
return functools.reduce(lambda l, r: l if issubclass(l, r) else r, tps) # noqa: E741
return functools.reduce(lambda x, y: x if issubclass(x, y) else y, tps)
if self.__origin__ is Callable.__origin__ and isinstance(arg, Callable):
return subtype(Callable.__origin__, *get_type_hints(arg).values())
if not isinstance(arg, self.__origin__): # no need to check subscripts
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ multimethod = ["py.typed"]
line-length = 100
skip-string-normalization = true

[tool.ruff]
ignore = ["E501", "F811"]

[tool.coverage.run]
source = ["multimethod"]
branch = true
4 changes: 2 additions & 2 deletions tests/test_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,11 @@ def f(x: enum.Enum):

def test_name_shadowing():
# an object with the same name appearing previously in the same namespace
temp = 123 # noqa
temp = 123

# a multimethod shadowing that name
@multimethod
def temp(x: int): # noqa
def temp(x: int):
return "int"

@multimethod
Expand Down

0 comments on commit d3560af

Please sign in to comment.