Skip to content

Commit

Permalink
chore: clean up pylint (scikit-build#1017)
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
  • Loading branch information
henryiii authored Jul 25, 2023
1 parent 9fb550b commit 08aa7ca
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 10 deletions.
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,14 @@ messages_control.disable = [
"too-many-branches",
"too-many-locals",
"too-many-statements",
"too-many-lines",
"too-many-return-statements",
"too-many-locals",
"ungrouped-imports",
"wrong-import-order",
"wrong-import-position",
"global-statement", # Covered by Ruff
"unused-import", # Covered by Ruff
]


Expand Down
2 changes: 1 addition & 1 deletion skbuild/cmaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def configure(
cmd.append(f"{prefix}_FIND_IMPLEMENTATIONS:STRING=PyPy")

with contextlib.suppress(ImportError):
import numpy as np
import numpy as np # pylint: disable=import-outside-toplevel

cmd.append(f"{prefix}_NumPy_INCLUDE_DIRS:PATH=" + np.get_include())

Expand Down
1 change: 1 addition & 0 deletions skbuild/command/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class CommandMixinProtocol(Protocol):
install_lib: str | None
install_platlib: str

# pylint: disable-next=missing-function-docstring
def finalize_options(self, *args: object, **kwargs: object) -> None:
...

Expand Down
3 changes: 1 addition & 2 deletions skbuild/platform_specifics/cygwin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from .abstract import CMakeGenerator


# pylint:disable=abstract-method
class CygwinPlatform(abstract.CMakePlatform):
"""Cygwin implementation of :class:`.abstract.CMakePlatform`."""

Expand All @@ -21,7 +20,7 @@ def __init__(self) -> None:
def generator_installation_help(self) -> str:
"""Return message guiding the user for installing a valid toolchain."""

pyver = "{}.{}".format(*sys.version_info[:2])
pyver = ".".join(str(v) for v in sys.version_info[:2])
return textwrap.dedent(
f"""\
Building Cygwin wheels for Python {pyver} requires Cygwin packages
Expand Down
2 changes: 2 additions & 0 deletions skbuild/platform_specifics/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@


class CachedEnv(TypedDict):
"""Stored environment."""

PATH: str
INCLUDE: str
LIB: str
Expand Down
13 changes: 7 additions & 6 deletions skbuild/setuptools_wrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,10 @@ def _load_cmake_spec() -> Any:


def get_default_include_package_data() -> bool:
# Include package data if pyproject.toml contains the project or tool.setuptools table.
"""
Include package data if pyproject.toml contains the project or
tool.setuptools table.
"""
# https://setuptools.pypa.io/en/latest/history.html#id255
# https://github.com/pypa/setuptools/pull/3067
pyproject_file = os.path.join(os.getcwd(), "pyproject.toml")
Expand All @@ -380,7 +383,6 @@ def get_default_include_package_data() -> bool:
return False


# pylint:disable=too-many-locals, too-many-branches
def setup(
*,
cmake_args: Sequence[str] = (),
Expand Down Expand Up @@ -620,9 +622,8 @@ def setup(
# taking care of it below.

# A local "cmake" folder can be imported by mistake, keep going if it is
from cmake import (
CMAKE_BIN_DIR, # pylint: disable=import-outside-toplevel
)
# pylint: disable-next=import-outside-toplevel
from cmake import CMAKE_BIN_DIR

for executable_name in ("cmake", "cpack", "ctest"):
executable = os.path.join(CMAKE_BIN_DIR, executable_name)
Expand Down Expand Up @@ -768,7 +769,7 @@ def setup(

# Adapted from espdev/ITKPythonInstaller/setup.py.in
class BinaryDistribution(upstream_Distribution): # pylint: disable=missing-class-docstring
def has_ext_modules(self) -> bool: # pylint: disable=no-self-use,missing-function-docstring
def has_ext_modules(self) -> bool: # pylint: disable=missing-function-docstring
return has_cmakelists

kw["distclass"] = BinaryDistribution
Expand Down
6 changes: 5 additions & 1 deletion skbuild/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@


class CommonLog(Protocol):
"""Protocol for loggers with an info method."""

# pylint: disable-next=missing-function-docstring
def info(self, __msg: str, *args: object) -> None:
...

Expand All @@ -43,6 +46,8 @@ def info(self, __msg: str, *args: object) -> None:


class Distribution(NamedTuple):
"""Distribution stand-in."""

script_name: str


Expand All @@ -51,7 +56,6 @@ def _log_warning(msg: str, *args: object) -> None:
if logging_module:
skb_log.warning(msg, *args)
else:
# pylint: disable-next=deprecated-method
distutils_log.warn(msg, *args)
except ValueError:
# Setuptools might disconnect the logger. That shouldn't be an error for a warning.
Expand Down

0 comments on commit 08aa7ca

Please sign in to comment.