From 3087e1c329738600ecd64a6079bbbe99a8951e88 Mon Sep 17 00:00:00 2001 From: Joshua Hamilton Date: Sat, 10 Aug 2024 13:18:28 -0500 Subject: [PATCH] mypy contributing (#51) * move pytest.ini & mypy.ini into pyproject.toml * add instructions in CONTRIBUTING for type-checking --- CONTRIBUTING.md | 11 ++++++++--- mypy.ini | 3 --- pyproject.toml | 5 +++++ pytest.ini | 2 -- 4 files changed, 13 insertions(+), 8 deletions(-) delete mode 100644 mypy.ini delete mode 100644 pytest.ini diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8aa8066..2a0ad2b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -36,13 +36,13 @@ Now you're ready to make changes to `src/fsrs` and see your changes reflected im This project follows [semantic versioning](https://semver.org/), so please make sure to increment the version number in [pyproject.toml](pyproject.toml) when contributing new code. -### Lint, format and test +### Lint, type-check, format and test -Py-FSRS uses [Ruff](https://github.com/astral-sh/ruff) for linting and formatting and uses [pytest](https://docs.pytest.org) to run its tests. In order for your contribution to be accepted, your code must pass linting/formatting checks and be able to pass the tests. +Py-FSRS uses [Ruff](https://github.com/astral-sh/ruff) for linting and formatting, [mypy](https://mypy-lang.org/) for static type-checking and [pytest](https://docs.pytest.org) to run its tests. In order for your contribution to be accepted, your code must pass the linting, type-checking and formatting checks as well as the tests. You can install these packages with ``` -pip install ruff pytest +pip install ruff mypy pytest ``` Lint your code with: @@ -50,6 +50,11 @@ Lint your code with: ruff check --fix ``` +Run the type-checker: +``` +mypy . +``` + Format your code with: ``` ruff format diff --git a/mypy.ini b/mypy.ini deleted file mode 100644 index ebcf395..0000000 --- a/mypy.ini +++ /dev/null @@ -1,3 +0,0 @@ -[mypy] -ignore_missing_imports = True - diff --git a/pyproject.toml b/pyproject.toml index 6e63dda..3829194 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,3 +23,8 @@ Homepage = "https://github.com/open-spaced-repetition/py-fsrs" [tool.ruff.lint] ignore = ["F401", "F403", "F405", "E721"] +[tool.pytest.ini_options] +pythonpath = "src" + +[tool.mypy] +ignore_missing_imports = true \ No newline at end of file diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index b893048..0000000 --- a/pytest.ini +++ /dev/null @@ -1,2 +0,0 @@ -[pytest] -pythonpath = src \ No newline at end of file