Skip to content

Commit

Permalink
Tin/fix-local (#15)
Browse files Browse the repository at this point in the history
* Add test

* Fix local var error

* Update actions/checkout
  • Loading branch information
Tinche authored Apr 8, 2024
1 parent 1f95040 commit 3255b20
Show file tree
Hide file tree
Showing 18 changed files with 128 additions and 123 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy-3.8"]

steps:
- uses: "actions/checkout@v3"
- uses: "actions/checkout@v4"

- uses: "actions/setup-python@v4"
with:
Expand Down Expand Up @@ -47,7 +47,7 @@ jobs:
runs-on: "ubuntu-latest"

steps:
- uses: "actions/checkout@v3"
- uses: "actions/checkout@v4"

- uses: "actions/setup-python@v4"
with:
Expand All @@ -72,6 +72,9 @@ jobs:
export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])")
echo "total=$TOTAL" >> $GITHUB_ENV
# Report again and fail if under the threshold.
python -Im coverage report --fail-under=99
- name: "Upload HTML report."
uses: "actions/upload-artifact@v3"
with:
Expand All @@ -97,7 +100,7 @@ jobs:
runs-on: "ubuntu-latest"

steps:
- uses: "actions/checkout@v3"
- uses: "actions/checkout@v4"

- uses: "actions/setup-python@v4"
with:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ The **first number** of the version is the year.
The **second number** is incremented with each release, starting at 1 for each year.
The **third number** is when we need to start branches for older releases (only for emergencies).

## 24.1.0 (UNRELEASED)

- Fix a code generation issue with context managers, and generate prettier code (for inspection).
([#15](https://github.com/Tinche/incant/pull/15))
- Use Ruff for import sorting.

## 23.2.0 (2023-10-30)

- `Incanter.(a)invoke()` has been renamed to {meth}`Incanter.(a)compose_and_call() <incant.Incanter.compose_and_call>` for clarity.
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ test:
pdm run pytest -xl tests/

lint:
pdm run ruff src/ tests && pdm run mypy src tests && pdm run black --check --quiet src tests && pdm run isort --check --quiet src tests
pdm run ruff check src/ tests && pdm run mypy src tests && pdm run black --check --quiet src tests
113 changes: 51 additions & 62 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 3 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ classifiers = [
requires-python = ">=3.8"
description = "Magical function composition"
readme = "README.md"
dependencies = ["attrs"]
dependencies = ["attrs>=20.1.0"]
license = {file = "LICENSE"}
dynamic = ["version"]

Expand All @@ -41,7 +41,6 @@ test = [
]
lint = [
"black>=23.3.0",
"isort>=5.11.4",
"ruff>=0.0.272",
"mypy>=0.991",
]
Expand All @@ -54,9 +53,6 @@ docs = [
"sphinx-copybutton>=0.5.2",
]

[tool.isort]
profile = "attrs"

[tool.pytest.ini_options]
asyncio_mode = "auto"

Expand All @@ -68,8 +64,7 @@ warn_redundant_casts = true
parallel = true
source_pkgs = ["incant"]

[tool.ruff]
src = ["src", "tests"]
[tool.ruff.lint]
select = [
"E", # pycodestyle
"W", # pycodestyle
Expand All @@ -90,12 +85,12 @@ select = [
"PIE", # flake8-pie
"RUF", # ruff
"ARG", # flake8-unused-arguments
"I", # isort
]
ignore = [
"E501", # line length is handled by black
"S101", # assert
"S307", # Eval
"PGH001", # No eval lol?
"PGH003", # leave my type: ignores alone
"B008", # can't get it to work with extend-immutable-calls
]
Expand Down
9 changes: 5 additions & 4 deletions src/incant/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
Union,
)

from attr import Factory, define, field, frozen
from attrs import Factory, define, field, frozen

from ._codegen import (
CtxManagerKind,
Expand All @@ -26,7 +26,6 @@
)
from ._compat import NO_OVERRIDE, Override, get_annotated_override, signature


__all__ = ["NO_OVERRIDE", "Override", "Hook", "Incanter", "IncantError"]

_type = type
Expand Down Expand Up @@ -64,14 +63,16 @@ class Hook:

@classmethod
def for_name(cls, name: str, hook: Optional[Callable]) -> "Hook":
return cls(lambda p: p.name == name, None if hook is None else (lambda _: hook, None)) # type: ignore
return cls(
lambda p: p.name == name, None if hook is None else (lambda _: hook, None)
)

@classmethod
def for_type(cls, type: Any, hook: Optional[Callable]) -> "Hook":
"""Register by exact type (subclasses won't match)."""
return cls(
lambda p: p.annotation == type,
None if hook is None else (lambda _: hook, None), # type: ignore
None if hook is None else (lambda _: hook, None),
)


Expand Down
Loading

0 comments on commit 3255b20

Please sign in to comment.