Skip to content

Commit

Permalink
fix: pylint import outside toplevel
Browse files Browse the repository at this point in the history
Co-authored-by: csteiner <[email protected]>
  • Loading branch information
akaihola and clintonsteiner committed Oct 28, 2024
1 parent 05b06b1 commit 1026778
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/darker/formatters/black_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ def read_config(self, src: tuple[str, ...], args: Namespace) -> None:

def _read_config_file(self, config_path: str) -> None: # noqa: C901
# Local import so Darker can be run without Black installed
from black import parse_pyproject_toml, re_compile_maybe_verbose
from black import ( # pylint: disable=import-outside-toplevel
parse_pyproject_toml,
re_compile_maybe_verbose,
)

raw_config = parse_pyproject_toml(config_path)
if "line_length" in raw_config:
Expand Down Expand Up @@ -151,7 +154,7 @@ def run(self, content: TextDocument) -> TextDocument:
"""
# Local import so Darker can be run without Black installed
from black import format_str
from black import format_str # pylint: disable=import-outside-toplevel

contents_for_black = content.string_with_newline("\n")
if contents_for_black.strip():
Expand All @@ -175,8 +178,8 @@ def _make_black_options(self) -> Mode:
# since at this point we already have a single file's content to work on.

# Local import so Darker can be run without Black installed
from black import FileMode as Mode
from black import TargetVersion
from black import FileMode as Mode # pylint: disable=import-outside-toplevel
from black import TargetVersion # pylint: disable=import-outside-toplevel

mode = BlackModeAttributes()
if "line_length" in self.config:
Expand Down

0 comments on commit 1026778

Please sign in to comment.