diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index 2e1e38e..0000000 --- a/.coveragerc +++ /dev/null @@ -1,12 +0,0 @@ -[run] -branch = True -omit = - *site-packages* - setup.py - -[report] -exclude_lines = - except ImportError: - if TYPE_CHECKING: - pragma: no cover - raise NotImplementedError diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c233f2f..8125f1a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,17 +16,16 @@ env: jobs: Test: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 strategy: matrix: include: - - python-version: '3.7' - - python-version: '3.8' - python-version: '3.9' - python-version: '3.10' - python-version: '3.11' - python-version: '3.12' - - python-version: '3.12' + - python-version: '3.13' + - python-version: '3.13' install-extra: '[sentry]' services: redis: @@ -37,50 +36,46 @@ jobs: REDIS_URL: 'redis://localhost:6379/0' SENTRY_DSN: 'http://user:pass@localhost:12340/foo' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v5 - name: 'Set up Python ${{ matrix.python-version }}' - uses: actions/setup-python@v4 + uses: astral-sh/setup-uv@v6 with: python-version: '${{ matrix.python-version }}' - - run: 'pip install -e ".$EXTRA" -e ".[test]"' + activate-environment: true + - run: 'uv pip install -e ".$EXTRA"' env: EXTRA: '${{ matrix.install-extra }}' - - run: py.test -vvv --cov . - - uses: codecov/codecov-action@v3 + - run: uv run pytest -vvv --cov . + - uses: codecov/codecov-action@v5 with: token: ${{ secrets.CODECOV_TOKEN }} name: 'Python ${{ matrix.python-version }}' Lint: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v4 - with: - python-version: '3.12' - - uses: pre-commit/action@v3.0.0 + - uses: actions/checkout@v5 + - uses: akx/pre-commit-uv-action@v0.1.0 Mypy: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v5 + - uses: astral-sh/setup-uv@v6 with: - python-version: '3.12' - - run: pip install -e .[sentry] mypy==1.0.0 types-redis - - run: mypy --strict --install-types --non-interactive --show-error-codes minique + python-version: '3.13' + - run: uv run --all-extras mypy --strict --install-types --non-interactive --show-error-codes minique Build: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 needs: [ Lint, Mypy, Test ] steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v5 + - uses: astral-sh/setup-uv@v6 with: - python-version: '3.12' - - run: pip install build twine - - run: python -m build . - - run: twine check dist/* + python-version: '3.13' + - run: uv build + - run: uvx twine check dist/* - uses: actions/upload-artifact@v4 with: name: build diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2463cf1..4551c37 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,15 +3,15 @@ ci: autofix_prs: false repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v6.0.0 hooks: - id: debug-statements - id: end-of-file-fixer - id: trailing-whitespace - - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.3.0 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.12.12 hooks: - - id: ruff + - id: ruff-check args: - --fix - id: ruff-format diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index efcf47c..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1 +0,0 @@ -recursive-include minique py.typed diff --git a/README.md b/README.md index 0dbe2c9..529a4fa 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # minique /miniːk/ -A minimal Redis 4.0+ job queue for Python 3.7 and above. +A minimal Redis 4.0+ job queue for Python 3.9 and above. ## Requirements -* Python 3.7+ +* Python 3.9+ * Redis 4.0+ ## Usage diff --git a/minique/cli.py b/minique/cli.py index cc685ae..93581e8 100644 --- a/minique/cli.py +++ b/minique/cli.py @@ -31,8 +31,7 @@ def main(argv: Optional[List[str]] = None) -> None: except Exception as exc: worker.log.warning("Failed to initialize Sentry: %s", exc, exc_info=True) else: - hub = sentry_sdk.hub.Hub.current - if hub and hub.client and hub.client.dsn: + if (client := sentry_sdk.get_client()) and client.is_active(): worker.log.info("Sentry configured with a valid DSN") if args.single_tick: diff --git a/minique/work/worker.py b/minique/work/worker.py index 9eb3e85..92e2a77 100644 --- a/minique/work/worker.py +++ b/minique/work/worker.py @@ -88,7 +88,7 @@ def process_exception( :param excinfo: Optionally, the sys.exc_info() 3-tuple """ if sentry_sdk: - with sentry_sdk.push_scope() as scope: + with sentry_sdk.new_scope() as scope: if context: scope.set_context("minique", context) sentry_sdk.capture_exception(excinfo) diff --git a/minique_tests/conftest.py b/minique_tests/conftest.py index 53ad9eb..2cf3cb3 100644 --- a/minique_tests/conftest.py +++ b/minique_tests/conftest.py @@ -38,6 +38,6 @@ def sentry_event_calls(monkeypatch) -> Optional[list]: return None client = sentry_sdk.Client(dsn="http://a:a@example.com/123") client.capture_event = Mock() - # TODO: this doesn't clean up the hub – maybe we don't need to? - sentry_sdk.Hub.current.bind_client(client) + # TODO: this doesn't clean up the global scope – maybe we don't need to? + sentry_sdk.get_global_scope().set_client(client) return client.capture_event.call_args_list diff --git a/mypy.ini b/mypy.ini deleted file mode 100644 index fefead9..0000000 --- a/mypy.ini +++ /dev/null @@ -1,4 +0,0 @@ -[mypy] - -[mypy-sentry_sdk.*] -ignore_missing_imports = True diff --git a/pyproject.toml b/pyproject.toml index 443dbd9..1b90ba9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ dynamic = ["version"] description = "Minimal Redis job runner" readme = "README.md" license = "MIT" -requires-python = ">=3.7" +requires-python = ">=3.9" authors = [ { name = "Valohai", email = "hait@valohai.com" }, ] @@ -18,11 +18,7 @@ dependencies = [ [project.optional-dependencies] sentry = [ - "sentry_sdk~=1.10", -] -test = [ - "pytest-cov", - "pytest>=6", + "sentry-sdk~=2.36", ] [project.scripts] @@ -53,7 +49,6 @@ filterwarnings = [ ] [tool.ruff] -target-version = "py37" line-length = 88 [tool.ruff.lint] @@ -74,3 +69,25 @@ select = [ [tool.ruff.lint.per-file-ignores] "minique_tests/**" = ["T2"] + +[dependency-groups] +dev = [ + "mypy>=1.4.1", + "pytest>=7.4.4", + "pytest-cov>=4.1.0", + "types-redis>=4.6.0.11", +] + +[tool.coverage.run] +branch = true +omit = [ + "*site-packages*", +] + +[tool.coverage.report] +exclude_also = [ + "except ImportError:", + "if TYPE_CHECKING:", + "pragma: no cover", + "raise NotImplementedError", +]