-
Notifications
You must be signed in to change notification settings - Fork 3
use hatch for lint/test + add development.md #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| name: CI | ||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| workflow_call: | ||
|
|
||
| jobs: | ||
| typecheck: | ||
| name: Type check | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| python: ["3.10", "3.11", "3.12", "3.13"] | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.13" | ||
| - uses: pypa/hatch@install | ||
| - run: hatch run types.py${{ matrix.python }}:check | ||
| fmt: | ||
| name: Format and lint | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.13" | ||
| - uses: pypa/hatch@install | ||
| - run: hatch fmt --check | ||
| test: | ||
| name: Test | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| python: ["3.10", "3.11", "3.12", "3.13"] | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ matrix.python }} | ||
| - uses: pypa/hatch@install | ||
| - run: hatch test -v --cover --include python=${{ matrix.python }} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| # Development | ||
|
|
||
| This project uses the [Hatch] project manager ([installation instructions][hatch-install]). | ||
|
|
||
| Hatch automatically manages dependencies and runs testing, type checking, and other operations in isolated [environments][hatch-environments]. | ||
|
|
||
| [Hatch]: https://hatch.pypa.io/ | ||
| [hatch-install]: https://hatch.pypa.io/latest/install/ | ||
| [hatch-environments]: https://hatch.pypa.io/latest/environment/ | ||
|
|
||
| ## Testing | ||
|
|
||
| You can run the tests on your local machine with: | ||
|
|
||
| ```bash | ||
| hatch test | ||
| ``` | ||
|
|
||
| The [`test` command][hatch-test] supports options such as `-c` for measuring test coverage, `-a` for testing with a matrix of Python versions, and appending an argument like `tests/test_validator.py::test_validate_expert_answer` for running a single test. | ||
|
|
||
| [hatch-test]: https://hatch.pypa.io/latest/tutorials/testing/overview/ | ||
|
|
||
| ## Type checking | ||
|
|
||
| You can run the [mypy static type checker][mypy] with: | ||
|
|
||
| ```bash | ||
| hatch run types:check | ||
| ``` | ||
|
|
||
| [mypy]: https://mypy-lang.org/ | ||
|
|
||
| ## Formatting and linting | ||
|
|
||
| You can run the [Ruff][ruff] formatter and linter with: | ||
|
|
||
| ```bash | ||
| hatch fmt | ||
| ``` | ||
|
|
||
| This will automatically make [safe fixes][fix-safety] to your code. If you want to only check your files without making modifications, run `hatch fmt --check`. | ||
|
|
||
| [ruff]: https://github.com/astral-sh/ruff | ||
| [fix-safety]: https://docs.astral.sh/ruff/linter/#fix-safety | ||
|
|
||
| ## Pre-commit | ||
|
|
||
| You can install the pre-commit hooks to automatically run type checking, formatting, and linting on every commit. | ||
|
|
||
| First, install [pre-commit][pre-commit], for example, with [pipx]: | ||
|
|
||
| ```bash | ||
| pipx install pre-commit | ||
| ``` | ||
|
|
||
| Then, install the hooks: | ||
|
|
||
| ```bash | ||
| pre-commit install | ||
| ``` | ||
|
|
||
| [pre-commit]: https://pre-commit.com/ | ||
| [pipx]: https://pipx.pypa.io/ | ||
|
|
||
| ## Packaging | ||
|
|
||
| You can use [`hatch build`][hatch-build] to create build artifacts, a [source distribution ("sdist")][sdist] and a [built distribution ("wheel")][bdist]. | ||
|
|
||
| [hatch-build]: https://hatch.pypa.io/latest/build/ | ||
| [sdist]: https://packaging.python.org/en/latest/glossary/#term-Source-Distribution-or-sdist | ||
| [bdist]: https://packaging.python.org/en/latest/glossary/#term-Built-Distribution | ||
|
|
||
| ### How to build and install the package locally | ||
|
|
||
| You may want to build and install the package locally - for example, to see how your changes affect other Python code in a script or Jupyter notebook. | ||
|
|
||
| To do this, you can build the package with `hatch build` and then install it in your local environment with `pip install dist/tlm-<version>-py3-none-any.whl`. | ||
|
|
||
| Alternatively, you can use `pip install -e /path/to/tlm` to install the package from your local code. Note that if you make further local changes after that, you may need to reload the module, i.e. `reload(tlm)`, or restart the kernel. | ||
|
|
||
| ## Continuous integration | ||
|
|
||
| Tests, type checking, and formatting/linting are [checked in the CI workflow][ci-workflow]. | ||
|
|
||
| [ci-workflow]: .github/workflows/ci.yml | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| __version__ = "0.0.0" |
Empty file.
Empty file.
Empty file.
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.