From 7565116c8b326757d13582af788464e1a26994a6 Mon Sep 17 00:00:00 2001 From: Maxim Kurnikov Date: Fri, 26 Apr 2019 10:45:43 +0300 Subject: add strict_optional = True for some files --- isort/compat.py | 2 +- isort/isort.py | 2 +- isort/natural.py | 2 +- isort/settings.py | 2 +- setup.cfg | 8 +++++++- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/isort/compat.py b/isort/compat.py index 6ea27d90..d3ea4ced 100644 --- a/isort/compat.py +++ b/isort/compat.py @@ -42,7 +42,7 @@ def read_file_contents(file_path: str, encoding: str, fallback_encoding: str) -> return None, None -def get_settings_path(settings_path: Optional[str], current_file_path: str) -> str: +def get_settings_path(settings_path: Optional[str], current_file_path: Optional[str]) -> str: if settings_path: return settings_path diff --git a/isort/isort.py b/isort/isort.py index a240a015..880952e0 100644 --- a/isort/isort.py +++ b/isort/isort.py @@ -193,7 +193,7 @@ class _SortImports(object): def _add_comments( self, - comments: Sequence[str], + comments: Optional[Sequence[str]], original_string: str = "" ) -> str: """ diff --git a/isort/natural.py b/isort/natural.py index 480e6ebf..7398d94d 100644 --- a/isort/natural.py +++ b/isort/natural.py @@ -46,6 +46,6 @@ def nsorted( key_callback = _natural_keys else: def key_callback(text: str) -> List[Any]: - return _natural_keys(key(text)) + return _natural_keys(key(text)) # type: ignore return sorted(to_sort, key=key_callback) diff --git a/isort/settings.py b/isort/settings.py index f7f20176..e0bf72ac 100644 --- a/isort/settings.py +++ b/isort/settings.py @@ -38,7 +38,7 @@ from .utils import difference, union try: import toml except ImportError: - toml = None + toml = None # type: ignore try: import appdirs diff --git a/setup.cfg b/setup.cfg index d4cf07e3..9574a5ce 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,9 +16,15 @@ license_file = LICENSE [mypy] follow_imports = silent ignore_missing_imports = True -strict_optional = False +strict_optional = True warn_no_return = False check_untyped_defs = True +[mypy-test_isort] +strict_optional = False + +[mypy-isort.isort] +strict_optional = False + [tool:pytest] testpaths = test_isort.py -- cgit v1.2.1