Skip to content

Commit

Permalink
Satisfy MyPy 0.812 using __all__
Browse files Browse the repository at this point in the history
MyPy strict mode now disallows implicit re-export.
See fastapi/typer#112 (comment)
  • Loading branch information
akaihola committed Apr 3, 2021
1 parent a2d1365 commit a362cc5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/darker/black_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
from black import FileMode as Mode
from black import TargetVersion, find_pyproject_toml, format_str, parse_pyproject_toml

__all__ = ["BlackArgs", "Mode", "run_black"]

logger = logging.getLogger(__name__)


Expand Down
2 changes: 1 addition & 1 deletion src/darker/command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def make_argument_parser(require_src: bool) -> ArgumentParser:
try:
import isort
except ImportError:
isort = None
isort = None # type: ignore
description.extend(
["", f"{ISORT_INSTRUCTION} to enable sorting of import definitions"]
)
Expand Down
11 changes: 9 additions & 2 deletions src/darker/import_sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,15 @@

try:
import isort
# Work around Mypy problem
# https://github.com/python/mypy/issues/7030#issuecomment-504128883
import isort.code as isort_code_
except ImportError:
isort = None
isort = None # type: ignore
isort_code_ = None
isort_code = isort_code_

__all__ = ["apply_isort", "isort"]

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -46,4 +53,4 @@ def apply_isort(
", ".join(f"{k}={v!r}" for k, v in isort_args.items())
)
)
return TextDocument.from_str(isort.code(code=content.string, **isort_args))
return TextDocument.from_str(isort_code(code=content.string, **isort_args))
2 changes: 1 addition & 1 deletion src/darker/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def run_isort(git_repo, monkeypatch, caplog, request):
), patch("darker.import_sorting.isort.code"):
darker.__main__.main(["--isort", "./test1.py", *args])
return SimpleNamespace(
isort_code=darker.import_sorting.isort.code, caplog=caplog
isort_code=darker.import_sorting.isort_code, caplog=caplog
)


Expand Down

0 comments on commit a362cc5

Please sign in to comment.