Skip to content

Commit 37a5863

Browse files
authored
Remove support for py37 and enable support for py312 (#122)
Remove support for py37 and enable support for py312
1 parent 3016449 commit 37a5863

9 files changed

+31
-24
lines changed

.pre-commit-config.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ repos:
1212
- id: end-of-file-fixer
1313
- id: trailing-whitespace
1414
- id: check-executables-have-shebangs
15+
- repo: https://github.com/asottile/pyupgrade
16+
rev: v3.3.1
17+
hooks:
18+
- id: pyupgrade
1519
- repo: https://github.com/psf/black
1620
rev: 22.12.0
1721
hooks:

pyproject.toml

+6-2
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ classifiers = [
2323
"Operating System :: POSIX :: Linux",
2424
"Programming Language :: Python",
2525
"Programming Language :: Python :: 3",
26-
"Programming Language :: Python :: 3.7",
2726
"Programming Language :: Python :: 3.8",
2827
"Programming Language :: Python :: 3.9",
2928
"Programming Language :: Python :: 3.10",
3029
"Programming Language :: Python :: 3.11",
30+
"Programming Language :: Python :: 3.12",
3131
"Topic :: System :: Systems Administration",
3232
"Topic :: Utilities",
3333
]
@@ -36,7 +36,7 @@ keywords = [
3636
"rst",
3737
"linter",
3838
]
39-
requires-python = ">=3.7"
39+
requires-python = ">=3.8"
4040
dependencies = [
4141
# Ceiled due to DeprecationWarning: The frontend.OptionParser class will be
4242
# replaced by a subclass of argparse.ArgumentParser in Docutils 0.21 or later.
@@ -71,13 +71,17 @@ filterwarnings = [
7171
]
7272

7373
[[tool.mypy.overrides]]
74+
python_version = "3.8"
7475
module = [
7576
"doc8._version",
7677
"restructuredtext_lint",
7778
"stevedore",
7879
]
7980
ignore_missing_imports = true
8081

82+
[tool.pylint.MAIN]
83+
py-version = "3.8.0"
84+
8185
[tool.pylint."MESSAGES CONTROL"]
8286

8387
disable = [

src/doc8/checks.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -313,5 +313,4 @@ def report_iter(self, parsed_file):
313313
checker_func = self._txt_checker
314314
else:
315315
checker_func = self._rst_checker
316-
for issue in checker_func(parsed_file):
317-
yield issue
316+
yield from checker_func(parsed_file)

src/doc8/main.py

+13-7
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def parse_ignore_path_errors(entries):
8585

8686
def from_ini(fp):
8787
parser = configparser.RawConfigParser()
88-
with open(fp, "r", encoding="utf-8") as fh:
88+
with open(fp, encoding="utf-8") as fh:
8989
parser.read_file(fh)
9090

9191
cfg = {}
@@ -275,10 +275,14 @@ def validate(cfg, files, result=None):
275275
line_num = "?"
276276
if cfg.get("verbose"):
277277
print(
278-
" - %s:%s: %s %s" % (f.filename, line_num, code, message)
278+
" - {}:{}: {} {}".format(
279+
f.filename, line_num, code, message
280+
)
279281
)
280282
elif not result.capture:
281-
print("%s:%s: %s %s" % (f.filename, line_num, code, message))
283+
print(
284+
"{}:{}: {} {}".format(f.filename, line_num, code, message)
285+
)
282286
result.error(check_name, f.filename, line_num, code, message)
283287
error_counts[check_name] += 1
284288
elif isinstance(c, checks.LineCheck):
@@ -293,12 +297,14 @@ def validate(cfg, files, result=None):
293297
)
294298
elif not result.capture:
295299
print(
296-
"%s:%s: %s %s" % (f.filename, line_num, code, message)
300+
"{}:{}: {} {}".format(
301+
f.filename, line_num, code, message
302+
)
297303
)
298304
result.error(check_name, f.filename, line_num, code, message)
299305
error_counts[check_name] += 1
300306
else:
301-
raise TypeError("Unknown check type: %s, %s" % (type(c), c))
307+
raise TypeError("Unknown check type: {}, {}".format(type(c), c))
302308
return error_counts
303309

304310

@@ -321,7 +327,7 @@ def get_defaults():
321327
}
322328

323329

324-
class Result(object):
330+
class Result:
325331
def __init__(self):
326332
self.files_selected = 0
327333
self.files_ignored = 0
@@ -360,7 +366,7 @@ def report(self):
360366
lines.append("Detailed error counts:")
361367
for check_name in sorted(self.error_counts.keys()):
362368
check_errors = self.error_counts[check_name]
363-
lines.append(" - %s = %s" % (check_name, check_errors))
369+
lines.append(" - {} = {}".format(check_name, check_errors))
364370

365371
return "\n".join(lines)
366372

src/doc8/parser.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import restructuredtext_lint as rl
2323

2424

25-
class ParsedFile(object):
25+
class ParsedFile:
2626
FALLBACK_ENCODING = "utf-8"
2727

2828
def __init__(self, filename, encoding=None, default_extension=""):
@@ -127,7 +127,7 @@ def contents(self):
127127
return self._content
128128

129129
def __str__(self):
130-
return "%s (%s, %s chars, %s lines)" % (
130+
return "{} ({}, {} chars, {} lines)".format(
131131
self.filename,
132132
self.encoding,
133133
len(self.contents),
@@ -137,5 +137,5 @@ def __str__(self):
137137

138138
def parse(filename, encoding=None, default_extension=""):
139139
if not os.path.isfile(filename):
140-
raise IOError(errno.ENOENT, "File not found", filename)
140+
raise OSError(errno.ENOENT, "File not found", filename)
141141
return ParsedFile(filename, encoding=encoding, default_extension=default_extension)

src/doc8/tests/test_checks.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
# Copyright (C) 2014 Yahoo! Inc. All Rights Reserved.
42
#
53
# Licensed under the Apache License, Version 2.0 (the "License"); you may

src/doc8/tests/test_main.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
import os
42
from io import StringIO
53
import unittest
@@ -79,7 +77,7 @@
7977
- doc8.checks.CheckValidity = 0"""
8078

8179

82-
class Capture(object):
80+
class Capture:
8381
"""
8482
Context manager to capture output on stdout and stderr
8583
"""
@@ -100,7 +98,7 @@ def __exit__(self, *args):
10098
sys.stderr = self.err
10199

102100

103-
class TmpFs(object):
101+
class TmpFs:
104102
"""
105103
Context manager to create and clean a temporary file area for testing
106104
"""
@@ -134,7 +132,7 @@ def expected(self, template):
134132
return template.format(path=self.path)
135133

136134

137-
class FakeResult(object):
135+
class FakeResult:
138136
"""
139137
Minimum valid result returned from doc8
140138
"""

src/doc8/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def path_ignorable(path):
5353
if extension_matches(path):
5454
yield (path, path_ignorable(path))
5555
else:
56-
raise IOError("Invalid path: %s" % path)
56+
raise OSError("Invalid path: %s" % path)
5757

5858

5959
def filtered_traverse(document, filter_func):

src/doc8/version.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
# Copyright (C) 2014 Yahoo! Inc. All Rights Reserved.
42
#
53
# Licensed under the Apache License, Version 2.0 (the "License"); you may

0 commit comments

Comments
 (0)