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

python: update required versions of black and mypy #5808

Merged
merged 2 commits into from
Mar 20, 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
4 changes: 1 addition & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ jobs:

python-lint:
name: python linting
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v5
with:
python-version: 3.6
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[tool.black]
profile = "black"
target-version = ['py36']
exclude = ["^env/", "^src/bindings/python/flux/utils/*/*.py", "^src/bindings/python/flux/utils/*/*/*.py"]
force-exclude = "/^(env/|src/bindings/python/flux/utils)/"

[tool.isort]
profile = "black" # needed for black/isort compatibility
Expand Down
4 changes: 2 additions & 2 deletions scripts/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
cffi>=1.1
ply>=3.9
pyyaml>=3.10.0
black==22.8.0
black==24.3.0
flake8>=5.0.4
isort>=5.9.3
mypy==0.971
mypy==1.9.0
pre-commit>=2.9.2
types-PyYAML
32 changes: 20 additions & 12 deletions src/bindings/python/flux/cli/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,25 +869,31 @@ def create_parser(
parser.add_argument(
"--input",
type=str,
help="Redirect job stdin from FILENAME, bypassing KVS"
if not exclude_io
else argparse.SUPPRESS,
help=(
"Redirect job stdin from FILENAME, bypassing KVS"
if not exclude_io
else argparse.SUPPRESS
),
metavar="FILENAME",
)
parser.add_argument(
"--output",
type=str,
help="Redirect job stdout to FILENAME, bypassing KVS"
if not exclude_io
else argparse.SUPPRESS,
help=(
"Redirect job stdout to FILENAME, bypassing KVS"
if not exclude_io
else argparse.SUPPRESS
),
metavar="FILENAME",
)
parser.add_argument(
"--error",
type=str,
help="Redirect job stderr to FILENAME, bypassing KVS"
if not exclude_io
else argparse.SUPPRESS,
help=(
"Redirect job stderr to FILENAME, bypassing KVS"
if not exclude_io
else argparse.SUPPRESS
),
metavar="FILENAME",
)
parser.add_argument(
Expand All @@ -900,9 +906,11 @@ def create_parser(
"-l",
"--label-io",
action="store_true",
help="Add rank labels to stdout, stderr lines"
if not exclude_io
else argparse.SUPPRESS,
help=(
"Add rank labels to stdout, stderr lines"
if not exclude_io
else argparse.SUPPRESS
),
)
parser.add_argument(
"--cwd", help="Set job working directory", metavar="DIRECTORY"
Expand Down
2 changes: 1 addition & 1 deletion src/bindings/python/flux/job/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ def __init__(self, fmt, headings=None, prepend=None):
creations of scheduler or user.
"""
format_list = string.Formatter().parse(fmt)
for (_, field, _, _) in format_list:
for _, field, _, _ in format_list:
if field and not field in self.headings:
if field.startswith("annotations."):
field_heading = field[len("annotations.") :].upper()
Expand Down
6 changes: 3 additions & 3 deletions src/bindings/python/flux/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ def header_format(self):
which will be made "safe" for use with string headings.
"""
format_list = []
for (text, field, spec, _) in self.format_list:
for text, field, spec, _ in self.format_list:
# Remove number formatting on any spec:
spec = re.sub(r"(0?\.)?(\d+)?[bcdoxXeEfFgGn%]$", r"\2", spec)

Expand Down Expand Up @@ -644,7 +644,7 @@ def get_format_prepended(self, prepend, except_fields=None):
if except_fields is None:
except_fields = []
lst = []
for (text, field, spec, conv) in self.format_list:
for text, field, spec, conv in self.format_list:
# Skip this field if it is in except_fields
if field in except_fields:
# Preserve any format "prefix" (i.e. the text):
Expand Down Expand Up @@ -704,7 +704,7 @@ def filter_empty(self, items):
#
lst = []
index = 0
for (text, field, _, conv) in self.format_list:
for text, field, _, conv in self.format_list:
if text.endswith("?:"):
fmt = self._fmt_tuple("", "0." + field, None, conv)
lst.append(dict(fmt=fmt, index=index))
Expand Down
8 changes: 5 additions & 3 deletions src/bindings/python/flux/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,11 @@ def __call__(self, calling_object, *args_in):
raise EnvironmentError(
errnum,
"{}: {}".format(
errno.errorcode[errnum]
if errnum in errno.errorcode
else "Errno" + str(errnum),
(
errno.errorcode[errnum]
if errnum in errno.errorcode
else "Errno" + str(errnum)
),
os.strerror(errnum),
),
)
Expand Down
8 changes: 5 additions & 3 deletions src/cmd/flux-pgrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,11 @@ def parse_args():
parser.add_argument(
"-a",
action="store_true",
help="Target jobs in all states"
if PROGRAM == "flux-pgrep"
else argparse.SUPPRESS,
help=(
"Target jobs in all states"
if PROGRAM == "flux-pgrep"
else argparse.SUPPRESS
),
)
parser.add_argument("-A", action="store_true", help="Target all users")
parser.add_argument(
Expand Down
4 changes: 2 additions & 2 deletions src/test/generate-matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def __str__(self):
)

# Debian: arm64, expensive, only on master and tags, only install
if matrix.branch == 'master' or matrix.tag:
if matrix.branch == "master" or matrix.tag:
matrix.add_build(
name="bookworm - arm64",
image="bookworm",
Expand Down Expand Up @@ -296,7 +296,7 @@ def __str__(self):
" --localstatedir=/var"
" --with-flux-security"
),
docker_tag=True
docker_tag=True,
)

# inception
Expand Down
1 change: 0 additions & 1 deletion t/issues/t5308-kvsdir-initial-path.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@
jobdir2 = flux.job.job_kvs(handle, jobid)
if jobdir2["foo"] != "bar":
sys.exit(1)

1 change: 1 addition & 0 deletions t/job-manager/bulk-state.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

expected_states = ["NEW", "DEPEND", "PRIORITY", "SCHED", "RUN", "CLEANUP", "INACTIVE"]


# Return True if all jobs in the jobs dictionary have reached 'INACTIVE' state
def all_inactive(jobs):
for jobid in jobs:
Expand Down
2 changes: 1 addition & 1 deletion t/jobspec/summarize-minimal-jobspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def load_jobspec(stream, prefix=""):
data = stream.read().encode("utf-8")
jobspec = yaml.safe_load(data)
return jobspec
except (yaml.YAMLError) as e:
except yaml.YAMLError as e:
print("{}{}".format(prefix, e.problem))
sys.exit(1)

Expand Down
2 changes: 1 addition & 1 deletion t/jobspec/y2j.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
obj = yaml.safe_load(sys.stdin)
except (OSError, IOError) as e:
sys.exit("y2j: " + e.strerror)
except (yaml.YAMLError) as e:
except yaml.YAMLError as e:
sys.exit("y2j: " + e.problem)

json.dump(obj, sys.stdout, separators=(",", ":"))
1 change: 1 addition & 0 deletions t/python/tap/pycotap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
else:
from StringIO import StringIO


# Log modes
class LogMode(object):
LogToError, LogToDiagnostics, LogToYAML, LogToAttachment = range(4)
Expand Down
4 changes: 3 additions & 1 deletion t/scripts/strerror_symbol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import os
import sys

if len(sys.argv) != 2:
print("requires a single errno constant name or number and converts to strerror string")
print(
"requires a single errno constant name or number and converts to strerror string"
)

try:
print(os.strerror(getattr(errno, sys.argv[1])))
Expand Down