diff --git a/docs/changelog.md b/docs/changelog.md index 98bee96..0c42fde 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Removed - `STYLE_STRING_FORMAT_REGEX`, which is no longer used to find `{` style fields. [#75](https://github.com/nhairs/python-json-logger/pull/75) +### Changed +- Replaced MyPy with Pyrefly for type checking + ### Fixed - `%` style formats no longer treat the escaped literal `%%` as the start of a field, so `"%%(notafield)s"` is correctly read as literal text. [#75](https://github.com/nhairs/python-json-logger/pull/75) - `{` style formats now use `string.Formatter` (as `logging.StrFormatStyle.validate` does) to find fields, so escaped literal braces (`{{`/`}}`) are skipped and a conversion (`{message!r}`) or format spec (`{levelname:>8}`) is no longer treated as part of the field name. [#75](https://github.com/nhairs/python-json-logger/pull/75) diff --git a/docs/contributing.md b/docs/contributing.md index 1994477..2a98ef6 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -47,13 +47,13 @@ black src tests # Lint pylint --output-format=colorized src -mypy src tests +pyrefly check src tests # Tests pytest ``` -The above commands (`black`, `pylint`, `mypy`, `pytest`) should all be run before submitting a pull request. +The above commands (`black`, `pylint`, `pyrefly `, `pytest`) should all be run before submitting a pull request. If making changes to the documentation you can preview the changes locally using `mkdocs`. Changes to the `README.md` can be previewed using a tool like [`grip`](https://github.com/joeyespo/grip) (installable via `pip install grip`). diff --git a/docs/style-guide.md b/docs/style-guide.md index ab217c5..a925b23 100644 --- a/docs/style-guide.md +++ b/docs/style-guide.md @@ -15,9 +15,9 @@ We use automated tools to enforce a consistent code style and catch potential er * **Black:** For opinionated code formatting. * **Pylint:** For static code analysis and error detection. -* **MyPy:** For static type checking. +* **Pyrefly:** For static type checking. -Ensure these tools are run before committing code. Configuration for these tools can be found in `pyproject.toml`, `pylintrc`, and `mypy.ini` respectively. This guide primarily focuses on conventions not automatically verifiable by these tools. +Ensure these tools are run before committing code. Configuration for these tools can be found in `pyproject.toml`, `pylintrc`, and `pyrefly.toml` respectively. This guide primarily focuses on conventions not automatically verifiable by these tools. ## Imports diff --git a/mypy.ini b/mypy.ini deleted file mode 100644 index f8b1844..0000000 --- a/mypy.ini +++ /dev/null @@ -1 +0,0 @@ -[mypy] diff --git a/pyproject.toml b/pyproject.toml index e9f4714..db24d60 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,8 +49,7 @@ dev = [ "validate-pyproject[all]", "black", "pylint", - "mypy<2; implementation_name == 'pypy' and python_version < '3.11'", - "mypy; implementation_name != 'pypy' or python_version >= '3.11'", + "pyrefly", ## Test "pytest", "freezegun", diff --git a/pyrefly.toml b/pyrefly.toml new file mode 100644 index 0000000..f101c19 --- /dev/null +++ b/pyrefly.toml @@ -0,0 +1 @@ +preset = "default" diff --git a/tests/test_formatters.py b/tests/test_formatters.py index 3f12fcc..df32f98 100644 --- a/tests/test_formatters.py +++ b/tests/test_formatters.py @@ -38,9 +38,9 @@ ### ============================================================================ ALL_FORMATTERS: list[type[BaseJsonFormatter]] = [JsonFormatter] if pythonjsonlogger.ORJSON_AVAILABLE: - ALL_FORMATTERS.append(OrjsonFormatter) + ALL_FORMATTERS.append(OrjsonFormatter) # type: ignore[unbound-name] if pythonjsonlogger.MSGSPEC_AVAILABLE: - ALL_FORMATTERS.append(MsgspecFormatter) + ALL_FORMATTERS.append(MsgspecFormatter) # type: ignore[unbound-name] _LOGGER_COUNT = 0 diff --git a/tox.ini b/tox.ini index aeea355..707d512 100644 --- a/tox.ini +++ b/tox.ini @@ -21,4 +21,4 @@ commands = validate-pyproject pyproject.toml black --check --diff src tests pylint src - mypy src tests + pyrefly check src tests