diff --git a/.copier-answers.yml b/.copier-answers.yml new file mode 100644 index 0000000..666db88 --- /dev/null +++ b/.copier-answers.yml @@ -0,0 +1,37 @@ +# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY +_commit: 16ecf4e +_src_path: gh:pdhall99/python-project-template +author_email: 20580126+pdhall99@users.noreply.github.com +author_name: PD Hall +copyright_year: 2026 +docs_enabled: false +github_owner: pdhall99 +keywords: +- annotation +- anywidget +- data labeling +- data labelling +- human in the loop +- information extraction +- jupyter +- named entity recognition +- ner +- nlp +- notebook +- sequence labeling +- sequence labelling +- span annotation +- text annotation +- text labeling +- text labelling +- widget +package_name: spanmark +project_description: Annotate text datasets with labelled spans in Jupyter and other + notebook environments +project_name: spanmark +python_support: eol +runtime_dependencies: +- anywidget +- filelock>=3.16 +- ipython +- traitlets diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..db89a5d --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,28 @@ +version: 2 + +# Each update waits a week before proposing a new release (cooldown), so a +# compromised release has time to be noticed before it reaches the project. +updates: + # Workflow actions are pinned to commit SHAs with version comments, which + # Dependabot updates together. + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" + cooldown: + default-days: 7 + groups: + github-actions: + patterns: ["*"] + + # When this bumps ruff-pre-commit, bump ruff in pyproject.toml's check-code + # group to the same version in the same pull request. + - package-ecosystem: "pre-commit" + directory: "/" + schedule: + interval: "monthly" + cooldown: + default-days: 7 + groups: + pre-commit: + patterns: ["*"] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3422ee5..f496480 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,6 @@ on: - "[0-9]+.[0-9]+.[0-9]+" pull_request: branches: ["main"] - types: [ready_for_review] workflow_dispatch: permissions: @@ -16,13 +15,10 @@ permissions: env: RUNNER: &runner "ubuntu-24.04" JOB_TIMEOUT: &job_timeout 30 + # The oldest supported Python: runs the tools, type checks and release checks. TOOL_PYTHON_VERSION: "3.11" - HATCH_VERSION: "1.18.1" + HATCH_VERSION: "1.18.2" UV_VERSION: "0.13.9" - DISTRIBUTION_NAME: "spanmark" - IMPORT_NAME: "spanmark" - DOCS_ENABLED: "false" - DOCS_DIR: "site" concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -62,7 +58,6 @@ jobs: timeout-minutes: *job_timeout outputs: matrix: ${{ steps.matrix.outputs.matrix }} - coverage_env: ${{ steps.matrix.outputs.coverage_env }} coverage_python: ${{ steps.matrix.outputs.coverage_python }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -106,19 +101,13 @@ jobs: if not rows: raise SystemExit("No Python versions found in the Hatch test matrix") - coverage = next( - ( - row - for row in rows - if row["python"] == os.environ["TOOL_PYTHON_VERSION"] - ), - rows[0], - ) + # Coverage is measured on one Python only, the newest: its tracer + # (sys.monitoring with branches, 3.14+) has the lowest overhead. + coverage = max(rows, key=lambda row: tuple(map(int, row["python"].split(".")))) with open(os.environ["GITHUB_OUTPUT"], "a") as output: matrix = json.dumps({"include": rows}, separators=(",", ":")) print(f"matrix={matrix}", file=output) - print(f"coverage_env={coverage['environment']}", file=output) print(f"coverage_python={coverage['python']}", file=output) PY @@ -151,7 +140,8 @@ jobs: - name: Install hatch run: uv tool install "hatch==$HATCH_VERSION" - - name: Run tests + - name: Run tests with coverage + if: matrix.python == needs.discover-tests.outputs.coverage_python env: TEST_ENVIRONMENT: ${{ matrix.environment }} TEST_PYTHON: ${{ matrix.python }} @@ -159,138 +149,26 @@ jobs: hatch test --python "$TEST_PYTHON" --cover hatch run "$TEST_ENVIRONMENT:cov-report-markdown" >> "$GITHUB_STEP_SUMMARY" - - name: Rename coverage files + - name: Run tests + if: matrix.python != needs.discover-tests.outputs.coverage_python env: TEST_PYTHON: ${{ matrix.python }} - run: | - shopt -s nullglob - files=(.coverage*) - if ((${#files[@]} == 0)); then - echo "No coverage files found" >&2 - exit 1 - fi - for f in "${files[@]}"; do - mv "$f" "$f.$TEST_PYTHON" - done + run: hatch test --python "$TEST_PYTHON" - - name: Upload coverage files - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 - with: - name: coverage-${{ matrix.python }} - path: .coverage* - compression-level: 0 - include-hidden-files: true - if-no-files-found: ignore - - coverage: - name: Coverage report - if: github.ref_type != 'tag' - runs-on: *runner - timeout-minutes: *job_timeout - needs: [discover-tests, test] - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - fetch-depth: 0 - persist-credentials: false - - - uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0 - with: - version: ${{ env.UV_VERSION }} - enable-cache: ${{ !startsWith(github.ref, 'refs/tags/') }} # zizmor: ignore[cache-poisoning] disabled for release tags - - - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 - with: - python-version: ${{ needs.discover-tests.outputs.coverage_python }} - - - name: Install hatch - run: uv tool install "hatch==$HATCH_VERSION" - - - name: Download coverage artifacts - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 - with: - pattern: coverage* - merge-multiple: true - - - name: Combine and report - env: - COVERAGE_ENVIRONMENT: ${{ needs.discover-tests.outputs.coverage_env }} - run: | - hatch run "$COVERAGE_ENVIRONMENT:cov-combine" - hatch run "$COVERAGE_ENVIRONMENT:cov-report" - hatch run "$COVERAGE_ENVIRONMENT:cov-report-markdown" >> "$GITHUB_STEP_SUMMARY" - - - name: Upload HTML report + - name: Upload HTML coverage report + if: matrix.python == needs.discover-tests.outputs.coverage_python uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: name: coverage-report path: htmlcov/ - docs: - name: Build docs - if: github.ref_type != 'tag' - runs-on: *runner - timeout-minutes: *job_timeout - outputs: - enabled: ${{ steps.config.outputs.enabled }} - steps: - - name: Read docs configuration - id: config - run: echo "enabled=$DOCS_ENABLED" >> "$GITHUB_OUTPUT" - - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - if: steps.config.outputs.enabled == 'true' - with: - fetch-depth: 0 - persist-credentials: false - - - uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0 - if: steps.config.outputs.enabled == 'true' - with: - version: ${{ env.UV_VERSION }} - enable-cache: ${{ !startsWith(github.ref, 'refs/tags/') }} # zizmor: ignore[cache-poisoning] disabled for release tags - - - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 - if: steps.config.outputs.enabled == 'true' - with: - python-version: ${{ env.TOOL_PYTHON_VERSION }} - - - name: Install hatch - if: steps.config.outputs.enabled == 'true' - run: uv tool install "hatch==$HATCH_VERSION" - - - name: Build docs - if: steps.config.outputs.enabled == 'true' - run: hatch run docs:build - - - name: Upload Pages artifact - if: steps.config.outputs.enabled == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main' - uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4 - with: - path: ${{ env.DOCS_DIR }} - - pages: - name: Deploy docs - if: needs.docs.outputs.enabled == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main' - needs: docs - runs-on: *runner - timeout-minutes: *job_timeout - permissions: - pages: write - id-token: write - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4 - build: name: Build package runs-on: *runner timeout-minutes: *job_timeout needs: [precommit, test] + outputs: + distribution_name: ${{ steps.project.outputs.name }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -309,6 +187,19 @@ jobs: - name: Install hatch run: uv tool install "hatch==$HATCH_VERSION" + - name: Read project name + id: project + run: | + python - <<'PY' + import os + import tomllib + from pathlib import Path + + project = tomllib.loads(Path("pyproject.toml").read_text())["project"] + with open(os.environ["GITHUB_OUTPUT"], "a") as output: + print(f"name={project['name']}", file=output) + PY + - name: Validate release tag if: github.ref_type == 'tag' env: @@ -330,6 +221,8 @@ jobs: - name: Extract release notes if: github.ref_type == 'tag' + env: + DISTRIBUTION_NAME: ${{ steps.project.outputs.name }} run: | mkdir -p release-notes awk -v heading="## [$GITHUB_REF_NAME]" ' @@ -357,18 +250,37 @@ jobs: - name: Build run: hatch build - - name: Smoke-test release wheel - if: github.ref_type == 'tag' + # Runs on every build, so packaging problems show up before a release. + # Only a release tag also checks the version against the tag. + - name: Smoke-test wheel + env: + TAG: ${{ github.ref_type == 'tag' && github.ref_name || '' }} run: | uv venv --python "$TOOL_PYTHON_VERSION" /tmp/package-smoke uv pip install --python /tmp/package-smoke/bin/python dist/*.whl - TAG="$GITHUB_REF_NAME" /tmp/package-smoke/bin/python - <<'PY' + /tmp/package-smoke/bin/python - <<'PY' import os + from email.parser import HeaderParser from importlib import import_module from importlib.metadata import version - - assert version(os.environ["DISTRIBUTION_NAME"]) == os.environ["TAG"] - import_module(os.environ["IMPORT_NAME"]) + from pathlib import Path + from zipfile import ZipFile + + # Both names come from the wheel's own metadata (PEP 794 Import-Name). + (wheel,) = Path("dist").glob("*.whl") + with ZipFile(wheel) as zf: + (meta,) = [n for n in zf.namelist() if n.endswith(".dist-info/METADATA")] + metadata = HeaderParser().parsestr(zf.read(meta).decode()) + + name = metadata["Name"] + import_names = [ + n.split(";")[0].strip() for n in metadata.get_all("Import-Name", []) + ] + assert import_names, f"{wheel.name} has no Import-Name: set import-names" + if os.environ["TAG"]: + assert version(name) == os.environ["TAG"], (version(name), os.environ["TAG"]) + for import_name in import_names: + import_module(import_name) PY - name: Upload release distributions @@ -395,7 +307,7 @@ jobs: - test - build steps: - - name: Require precommit, test, build + - name: Require every check env: PRECOMMIT: ${{ needs.precommit.result }} TEST: ${{ needs.test.result }} @@ -411,7 +323,7 @@ jobs: runs-on: *runner environment: name: pypi - url: https://pypi.org/project/spanmark/ + url: ${{ format('https://pypi.org/project/{0}/', needs.build.outputs.distribution_name) }} timeout-minutes: *job_timeout needs: build permissions: @@ -432,7 +344,7 @@ jobs: if: github.ref_type == 'tag' runs-on: *runner timeout-minutes: *job_timeout - needs: pypi + needs: [build, pypi] permissions: contents: write steps: @@ -452,6 +364,7 @@ jobs: env: GH_TOKEN: ${{ github.token }} GH_REPO: ${{ github.repository }} + DISTRIBUTION_NAME: ${{ needs.build.outputs.distribution_name }} run: | gh release create "$GITHUB_REF_NAME" dist/* \ --title "$DISTRIBUTION_NAME $GITHUB_REF_NAME" \ diff --git a/.gitignore b/.gitignore index 52e5f23..5d5bf1b 100644 --- a/.gitignore +++ b/.gitignore @@ -47,6 +47,7 @@ nosetests.xml coverage.xml *.cover *.py.cover +*.lcov .hypothesis/ .pytest_cache/ cover/ @@ -122,13 +123,14 @@ ipython_config.py # pixi.lock # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one # in the .venv directory. It is recommended not to include this directory in version control. -.pixi +.pixi/* +!.pixi/config.toml # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm __pypackages__/ # Celery stuff -celerybeat-schedule +celerybeat-schedule* celerybeat.pid # Redis diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 80a0d4d..0817bdd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,16 +18,18 @@ repos: - id: mixed-line-ending - id: name-tests-test args: [--pytest-test-first] + # Test helper modules start with an underscore + exclude: ^tests/(.*/)?_[^/]*\.py$ - id: trailing-whitespace args: [--markdown-linebreak-ext=md] - repo: https://github.com/tox-dev/pyproject-fmt - rev: v2.30.3 + rev: v2.31.2 hooks: - id: pyproject-fmt - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.17.1 # keep consistent with hatch config + rev: v0.17.6 # keep consistent with hatch config hooks: # Run the linter - id: ruff-check @@ -44,7 +46,7 @@ repos: - id: actionlint - repo: https://github.com/zizmorcore/zizmor-pre-commit - rev: v1.31.1 + rev: v1.33.1 hooks: - id: zizmor diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..f64b4af --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,3 @@ +# Agent instructions + +Follow the [contributor guide](docs/CONTRIBUTING.md), in particular [running commands](docs/CONTRIBUTING.md#running-commands). diff --git a/README.md b/README.md index a289a79..36584c1 100644 --- a/README.md +++ b/README.md @@ -394,13 +394,13 @@ For releases before `1.0.0`, the public API should be considered under developme ### Python-version compatibility -This project supports Python feature releases from their official final release until their official end-of-life (EOL). +This project supports Python feature releases from their official final release until their [official end-of-life](https://devguide.python.org/versions/). Support for a new Python feature release is generally introduced in the first minor release of this project following the upstream Python release. Python feature releases may be dropped once they reach the end of their upstream support cycle. The currently supported Python versions are declared in the package metadata. -Dropping an EOL Python version is considered a change to the supported runtime environment rather than a backwards-incompatible change to this project's public API, and therefore does not by itself require a new major release. +Dropping an end-of-life Python version is considered a change to the supported runtime environment rather than a backwards-incompatible change to this project's public API, and therefore does not by itself require a new major release. ## Acknowledgements diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 1ecdf00..03e2575 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -2,6 +2,11 @@ ## [Unreleased] +### Added + +- `Import-Name` package metadata ([PEP 794](https://peps.python.org/pep-0794/)), declaring `spanmark` as the import name +- `py.typed` marker, so type checkers use the package's type annotations + ### Removed - Support for Python 3.10, making Python 3.11 the minimum supported version diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index bc633be..10da37c 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -10,6 +10,23 @@ Contributions can include: - Adding or improving tests - Making code changes +This guide covers: + +- [Raising issues](#raising-issues) + - [Reporting bugs](#reporting-bugs) + - [Suggesting changes](#suggesting-changes) +- [Making changes](#making-changes) + - [Setting up your environment](#setting-up-your-environment) + - [Working on a branch](#working-on-a-branch) + - [Changing documentation](#changing-documentation) + - [Changing code](#changing-code) + - [Checking your changes](#checking-your-changes) + - [Opening a pull request](#opening-a-pull-request) +- [Maintaining the project](#maintaining-the-project) + - [Releasing a version](#releasing-a-version) + - [Updating from the template](#updating-from-the-template) +- [Running commands](#running-commands) + ## Raising issues Use GitHub issues to report bugs or suggest changes. @@ -49,7 +66,9 @@ Where useful, include: For substantial changes, please raise an issue before starting implementation, so that any decisions can be made before significant work is done. -## Prerequisites +## Making changes + +### Setting up your environment For code contributions you will need: @@ -57,13 +76,11 @@ For code contributions you will need: - A development environment with: - Python 3.11 (the minimum version of Python supported) - - `hatch>=1.17` + - `hatch>=1.18` - Access to the internet for GitHub and installation of packages from PyPI If Hatch is not available in your development environment, see the [Hatch installation instructions](https://hatch.pypa.io/latest/install/). -## Setup - The project uses Hatch to manage Python environments for development. To set up your development environment, run @@ -72,7 +89,7 @@ To set up your development environment, run hatch run pre-commit:install ``` -## Workflow +### Working on a branch To make a contribution: @@ -89,9 +106,15 @@ Unrelated changes are easier to review when submitted separately. Documentation-only and other non-code contributions can use the same workflow. Only the checks and definition-of-done items relevant to the change need to apply. -### During development +### Changing documentation + +#### Writing Markdown + +Write Markdown prose with one sentence per source line. -#### Testing +### Changing code + +#### Running tests `hatch test` passes any arguments after its own flags through to `pytest`, so during development you can narrow to one file or test rather than running the full matrix each time: @@ -106,13 +129,20 @@ Use these commands for a fast iterative development loop. Run the full `hatch test --all` matrix before opening a pull request. +The `tests/` directory should mirror the package structure under `src/spanmark/`. +Test modules are named `test_*.py`; name helper modules in `tests/` with a leading underscore, such as `_helpers.py`. + #### Adding dependencies Add dependencies in `pyproject.toml`. -The core package is intentionally dependency-free; a new runtime dependency requires a design-level justification. +#### Writing docstrings + +Use concise Google-style docstrings. +Let annotations carry types and signatures carry ordinary defaults. +Avoid boilerplate documentation that merely repeats the signature. -### Checks +### Checking your changes Pull requests must pass checks in CI before they can be merged into main. @@ -131,12 +161,102 @@ After running the commands, review and commit the resulting changes — otherwis A clean run that leaves no changes means there was nothing to fix. -### Definition of done +### Opening a pull request + +Pull requests are squash-merged, with the pull request title as the commit message. +Write the title as a short summary of the change in the imperative, such as "Add support for X". Changes are ready for review when all applicable items below are complete: - Relevant tests have been added or updated in the `tests/` directory - Relevant documentation has been added to or updated in the `docs/` directory - Relevant Google-style docstrings have been added or updated +- User-facing changes are recorded under `## [Unreleased]` in `docs/CHANGELOG.md` - All applicable checks above pass - Generated fixes from linting or formatting checks have been committed + +Record changes in `docs/CHANGELOG.md` under the [Keep a Changelog](https://keepachangelog.com/) headings `Added`, `Changed`, `Deprecated`, `Removed`, `Fixed` and `Security`. +Record only changes that affect users of the package, including changes to the supported Python versions. + +## Maintaining the project + +### Releasing a version + +Maintainers make releases by pushing a version tag to `main`. +CI does the rest: nothing is built or uploaded by hand. + +1. Choose the version number, `X.Y.Z`, following [Semantic Versioning](https://semver.org/). +2. In a pull request, move the unreleased changes in `docs/CHANGELOG.md` into a section for the release, and merge it: + + - Rename `## [Unreleased]` to `## [X.Y.Z] - YYYY-MM-DD`, and add a new, empty `## [Unreleased]` above it + - Update the links at the end of the file, for example for a first release: + + ```markdown + [Unreleased]: https://github.com/pdhall99/spanmark/compare/0.1.0...HEAD + [0.1.0]: https://github.com/pdhall99/spanmark/releases/tag/0.1.0 + ``` + + For later releases, compare `[Unreleased]` with the new version, and the new version with the previous one: + + ```markdown + [Unreleased]: https://github.com/pdhall99/spanmark/compare/0.2.0...HEAD + [0.2.0]: https://github.com/pdhall99/spanmark/compare/0.1.0...0.2.0 + ``` +3. Tag the merged commit on `main`, and push the tag: + + ```shell + git switch main + git pull + git tag X.Y.Z + git push origin X.Y.Z + ``` + + Tags are plain `X.Y.Z`, without a `v` prefix: the package version comes from the tag. +4. Follow the tag's CI run. + It checks the tag is `X.Y.Z` and on `main`, runs the checks and tests, builds the package, and checks the wheel's version matches the tag. +5. If the `pypi` environment requires approval, approve the deployment in the run (**Review deployments**). + CI then publishes to PyPI, and creates a GitHub release with the changelog section as its notes and the built package attached. + +If the run fails before publishing, for example because `docs/CHANGELOG.md` has no section for the tag, fix the problem through a pull request, then move the tag to the fixed commit: + +```shell +git push --delete origin X.Y.Z +git switch main +git pull +git tag --force X.Y.Z +git push origin X.Y.Z +``` + +Once a version is on PyPI it cannot be uploaded again, so release any fix as a new version. + +### Updating from the template + +This project was generated from a [Copier](https://copier.readthedocs.io/) template, recorded with your answers to its questions in `.copier-answers.yml`. + +To apply a newer version of the template, run + +```shell +uvx copier update --defaults +``` + +Review the changes and resolve any conflicts, where the project has changed the same lines as the template, then commit them through a pull request. + +A template update can change the supported Python versions; record any change to them in `docs/CHANGELOG.md`. + +## Running commands + +Run every development command through Hatch, which manages the environments for the project: don't install packages with `pip` or run tools such as `pytest` or `ruff` directly. + +- Don't skip pre-commit hooks or checks, for example with `git commit --no-verify` +- Don't edit `src/spanmark/_version.py`: it is generated from the git tag +- Commit any changes the checks make, as described in [checking your changes](#checking-your-changes) + +```shell +hatch run pre-commit:install # Set up the pre-commit hooks +hatch test # Run the tests on the default version of Python +hatch test --all # Run the tests on every version of Python in the matrix +hatch check code --fix # Check and fix linting and formatting +hatch check types # Check type annotations +hatch run pre-commit:ci # Run all pre-commit hooks +hatch build # Build the package +``` diff --git a/pyproject.toml b/pyproject.toml index 1ef47b5..5a83246 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,12 +1,13 @@ # [build-system] [build-system] build-backend = "hatchling.build" -requires = [ "hatch-vcs", "hatchling" ] +requires = [ "hatch-vcs", "hatchling>=1.32" ] # -------------------------------------------------------------------------------------- # [project] [project] name = "spanmark" +import-names = [ "spanmark" ] description = """\ Annotate text datasets with labelled spans in Jupyter and other notebook \ environments\ @@ -82,14 +83,19 @@ test = [ "coverage-enable-subprocess==1", "pytest~=9.0", "pytest-mock~=3.12", - "pytest-randomly~=4.1", + "pytest-randomly~=5.0", "pytest-rerunfailures~=16.0", "pytest-sugar", "pytest-xdist[psutil]~=3.5", ] -check-code = [ "ruff==0.17.1" ] # keep consistent with pre-commit-config.yaml +check-code = [ "ruff==0.17.6" ] # keep consistent with pre-commit-config.yaml check-fmt = [ { include-group = "check-code" } ] -check-types = [ "pyrefly==1.4", { include-group = "test" } ] +check-types = [ "pyrefly==1.5", { include-group = "test" } ] + +# -------------------------------------------------------------------------------------- +# [tool.hatch] +[tool.hatch] +requires-hatch = ">=1.18" [tool.hatch.version.raw-options] version_scheme = "no-guess-dev" @@ -101,8 +107,6 @@ source = "vcs" [tool.hatch.metadata] allow-direct-references = true -# -------------------------------------------------------------------------------------- -# [tool.hatch] [tool.hatch.build.hooks.vcs] version-file = "src/spanmark/_version.py" @@ -138,8 +142,14 @@ dependencies = [] config-path = "pyproject.toml" dependency-groups = [ "check-types" ] +[tool.hatch.envs.hatch-static-analysis] +dependencies = [] +config-path = "pyproject.toml" +dependency-groups = [ "check-code" ] + [tool.hatch.envs.hatch-test] dependencies = [] +default-args = [] dependency-groups = [ "test" ] [[tool.hatch.envs.hatch-test.matrix]] @@ -214,7 +224,7 @@ column_width = 88 indent = 4 keep_full_version = false generate_python_version_classifiers = false -max_supported_python = "3.14" +max_supported_python = "3.15" table_format = "long" sub_table_spacing = "\n" separate_root_table = "\n" @@ -234,9 +244,13 @@ preset = "strict" # -------------------------------------------------------------------------------------- # [tool.pytest] -[tool.pytest.ini_options] -testpaths = [ "README.md", "tests" ] -addopts = "-ra -q --doctest-glob='*.md'" +[tool.pytest] +addopts = [ "-ra", "-q", "--doctest-modules", "--doctest-glob=*.md" ] +filterwarnings = [ "error" ] +log_level = "INFO" +minversion = "9.0" +strict = true +testpaths = [ "tests", "src/spanmark", "README.md" ] # -------------------------------------------------------------------------------------- # [tool.coverage] diff --git a/src/spanmark/py.typed b/src/spanmark/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_package.py b/tests/test_package.py new file mode 100644 index 0000000..ff8a6b7 --- /dev/null +++ b/tests/test_package.py @@ -0,0 +1,2 @@ +def test_import() -> None: + __import__("spanmark")