Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miscellaneous updates #473

Merged
merged 4 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
[flake8]
ignore = W503
ignore = W503,U101
per-file-ignores =
conf/*: D
docs/*: D
src/mpi4py/futures/_core.py: D,B036
src/mpi4py/futures/aplus.py: B036
src/mpi4py/futures/util.py: B036
src/mpi4py/typing.py: U100
src/mpi4py/util/pkl5.py: U100
unused-arguments-ignore-variadic-names = True
2 changes: 1 addition & 1 deletion .github/workflows/ci-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ jobs:
run: python -m pip install -U -r conf/requirements-lint.txt

- name: ruff
run: ruff .
run: ruff check .

- name: flake8
run: flake8 docs src
Expand Down
1 change: 1 addition & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ lint.select = [
"S",
"W",
"UP",
"ARG",
"ISC",
"PIE",
#"PTH",
Expand Down
2 changes: 0 additions & 2 deletions .spin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ name = 'mpi4py'
"Build" = [
".spin/cmds.py:build",
".spin/cmds.py:test",
".spin/cmds.py:clean",
".spin/cmds.py:sdist",
".spin/cmds.py:wheel",
]
"Environment" = [
".spin/cmds.py:shell",
".spin/cmds.py:ipython",
".spin/cmds.py:exec",
".spin/cmds.py:mpiexec",
".spin/cmds.py:mpi4py",
]
Expand Down
22 changes: 2 additions & 20 deletions .spin/cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
@click.option("-c", "--clean", is_flag=True, help="Clean build directory.")
@click.option("-f", "--force", is_flag=True, help="Force build everything.")
@click.option("-q", "--quiet", is_flag=True, help="Run quietly.")
@click.pass_context
def build(ctx, clean, force, quiet):
def build(clean, force, quiet):
"""🔧 Build in-place."""
opt_force = ["--force"] if force else []
opt_quiet = ["--quiet"] if quiet else []
Expand All @@ -36,14 +35,6 @@ def test(ctx, n, singleton, test_args):
run([*launcher, *PYTHON, "test/main.py", "--inplace", *test_args])


@click.command()
@click.option("-q", "--quiet", is_flag=True, help="Run quietly.")
def clean(quiet):
"""🔧 Clean build directory."""
opt_quiet = ["--quiet"] if quiet else []
run([*PYTHON, "setup.py", *opt_quiet, "clean", "--all"])


def _get_site_packages():
script = os.path.abspath(__file__)
testdir = os.path.dirname(script)
Expand Down Expand Up @@ -91,15 +82,6 @@ def ipython(ctx, ipython_args):
run([*ipython, *ipython_args], replace=True)


@click.command(context_settings={"ignore_unknown_options": True})
@click.argument("args", nargs=-1)
@click.pass_context
def exec(ctx, args):
"""🏁 Run command with PYTHONPATH set."""
_setup_environment(ctx)
run([*args], replace=True)


@click.command(context_settings={"ignore_unknown_options": True})
@click.option("-n", default=1, help="Number of MPI processes")
@click.argument("mpiexec_args", nargs=-1)
Expand Down Expand Up @@ -141,7 +123,7 @@ def install(editable, quiet, pip_args):
@click.option("-q", "--quiet", is_flag=True, help="Run quietly.")
@click.argument("pip_args", nargs=-1)
@click.pass_context
def editable(ctx, quiet, pip_args):
def editable(ctx, quiet, pip_args): # noqa: ARG001
"""🔧 Install package in editable mode."""
ctx.forward(install, editable=True)

Expand Down
2 changes: 1 addition & 1 deletion conf/cycoverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def line_is_excluded(_):
return code_lines, exec_lines, excluded_lines


def coverage_init(reg, options):
def coverage_init(reg, options): # noqa: ARG001
plugin = CythonCoveragePlugin()
reg.add_configurer(plugin)
reg.add_file_tracer(plugin)
6 changes: 3 additions & 3 deletions conf/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
import sys


def get_name(settings=None):
def get_name(settings=None): # noqa: ARG001
name = "mpi4py"
suffix = os.environ.get("MPI4PY_DIST_SUFFIX")
if suffix:
name = "{name}-{suffix}".format(**vars())
return name


def get_version(settings=None):
def get_version(settings=None): # noqa: ARG001
confdir = os.path.dirname(os.path.abspath(__file__))
topdir = os.path.dirname(confdir)
srcdir = os.path.join(topdir, "src")
Expand All @@ -25,7 +25,7 @@ def get_version(settings=None):
return version


def get_readme(settings=None):
def get_readme(settings=None): # noqa: ARG001
confdir = os.path.dirname(__file__)
topdir = os.path.dirname(confdir)
filelist = ("DESCRIPTION.rst", "CITATION.rst", "INSTALL.rst")
Expand Down
6 changes: 4 additions & 2 deletions conf/mpidistutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,8 @@ def cython_run(
args = []
if with_coverage():
args += ['-X', 'linetrace=True']
if includes:
args += [f'-I{incdir}' for incdir in includes]
if workdir:
args += ['--working', workdir]
args += [source]
Expand Down Expand Up @@ -948,7 +950,7 @@ def configure_mpi(ext, config_cmd):
configure_dl(ext, config_cmd)


def configure_pyexe(exe, config_cmd):
def configure_pyexe(exe, _config_cmd):
if sys.platform.startswith('win'):
return
if (sys.platform == 'darwin' and
Expand Down Expand Up @@ -1027,7 +1029,7 @@ def has_executables (self):
return self.distribution.has_executables()

sub_commands = [
('build_src', lambda *args: True),
('build_src', lambda *_: True),
*cmd_build.build.sub_commands,
('build_exe', has_executables),
]
Expand Down
2 changes: 1 addition & 1 deletion conf/mpistubgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ def Intersect(cls, group1: Group, group2: Group) -> Self: ...
"""


def visit_mpi4py_MPI(done=None):
def visit_mpi4py_MPI():
from mpi4py import MPI as module
lines = Lines()
lines.add = IMPORTS
Expand Down
1 change: 1 addition & 0 deletions conf/requirements-lint.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ flake8-assertive
flake8-bandit
flake8-bugbear
flake8-docstrings
flake8-unused-arguments
flake8-use-fstring
pylint
ruff
Expand Down
2 changes: 1 addition & 1 deletion docs/source/apidoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ def _def(cls, name):
"""


def visit_mpi4py_MPI(done=None):
def visit_mpi4py_MPI():
from mpi4py import MPI as module
lines = Lines()
lines.add = f'"""{module.__doc__}"""'
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class TypeDocumenter(autodoc.DataDocumenter):
priority = autodoc.ClassDocumenter.priority + 1

@classmethod
def can_document_member(cls, member, membername, isattr, parent):
def can_document_member(cls, member, _membername, _isattr, parent):
return (
isinstance(parent, autodoc.ModuleDocumenter)
and parent.name == 'mpi4py.typing'
Expand Down
2 changes: 1 addition & 1 deletion src/mpi4py/futures/aplus.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def catch(future, on_failure=None):

"""
if on_failure is None:
return then(future, None, lambda exc: None)
return then(future, None, lambda _: None)
return then(future, None, on_failure)


Expand Down
2 changes: 1 addition & 1 deletion src/mpi4py/util/pkl5.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ def recv(self,
return _recv(self, MPI.Comm.Recv, buf, source, tag, status)

def irecv(self,
buf=None, source=ANY_SOURCE, tag=ANY_TAG):
buf=None, source=ANY_SOURCE, tag=ANY_TAG): # noqa: ARG002
"""Nonblocking receive."""
raise RuntimeError("unsupported")

Expand Down
3 changes: 3 additions & 0 deletions test/test_errorcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def testException(self):
errstr = MPI.Get_error_string(ierr)
errcls = MPI.Get_error_class(ierr)
errexc = MPI.Exception(ierr)
self.assertEqual(errexc.Get_error_code(), ierr)
self.assertEqual(errexc.Get_error_class(), errcls)
self.assertEqual(errexc.Get_error_string(), errstr)
self.assertEqual(errexc.error_code, ierr)
self.assertEqual(errexc.error_class, errcls)
self.assertEqual(errexc.error_string, errstr)
Expand Down
3 changes: 3 additions & 0 deletions test/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ def assertRaisesMPI(self, IErrClass, callableObj, *args, **kwargs):
raise
except excClass as excValue:
error_class = excValue.Get_error_class()
else:
error_class = None
if error_class is not None:
if isinstance(IErrClass, (list, tuple, set)):
match = (error_class in IErrClass)
else:
Expand Down
2 changes: 1 addition & 1 deletion test/test_grequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def check_exc(exception, is_mpi, stderr):
else:
chkcode = MPI.ERR_OTHER
excname = ValueError.__name__
ierr = exception.Get_error_code()
ierr = exception.Get_error_class()
self.assertEqual(ierr, chkcode)
self.assertTrue(output.startswith(header))
self.assertIn(excname, output)
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ setenv =
MPICFG=nompi-fast
CFLAGS=-O0
commands =
ruff .
ruff check .
flake8 docs src
flake8 --select=A {toxinidir}/test
pylint mpi4py
Expand Down