From 44ed27f7be377d978e85f4a80bb7b0cbf88d2636 Mon Sep 17 00:00:00 2001 From: Tom Ritchford <tom@swirly.com> Date: Thu, 25 Jan 2024 11:14:24 +0100 Subject: [PATCH] Run mypy in strict mode --- editor/__init__.py | 7 +++---- pyproject.toml | 3 +++ test_editor.py | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/editor/__init__.py b/editor/__init__.py index 084685a..8ba4163 100644 --- a/editor/__init__.py +++ b/editor/__init__.py @@ -59,12 +59,12 @@ EDITORS = {'Windows': 'notepad'} -@xmod.xmod(mutable=True) +@xmod.xmod(mutable=True) # type: ignore[misc] def editor( text: t.Optional[str] = None, filename: t.Union[None, Path, str] = None, editor: t.Optional[str] = None, - **kwargs: t.Mapping, + **kwargs: t.Any, ) -> str: """ Open a text editor, block while the user edits, then return the results @@ -115,6 +115,5 @@ def default_editor() -> str: `'notepad'`, otherwise `'vim'`. """ return os.environ.get('VISUAL') or ( - os.environ.get('EDITOR') - or EDITORS.get(platform.system(), DEFAULT_EDITOR) + os.environ.get('EDITOR') or EDITORS.get(platform.system(), DEFAULT_EDITOR) ) diff --git a/pyproject.toml b/pyproject.toml index a7ef6d5..924473c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,6 +46,9 @@ line-length = 88 [tool.ruff.format] quote-style = "single" + +[tool.mypy] +strict = true [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" diff --git a/test_editor.py b/test_editor.py index 4736408..471ec3b 100644 --- a/test_editor.py +++ b/test_editor.py @@ -1,5 +1,5 @@ -from pathlib import Path import unittest +from pathlib import Path from unittest import mock import tdir