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

Remove support for py37 and enable support for py312 #122

Merged
merged 1 commit into from Dec 21, 2022
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: 4 additions & 0 deletions .pre-commit-config.yaml
Expand Up @@ -12,6 +12,10 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-executables-have-shebangs
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
- repo: https://github.com/psf/black
rev: 22.12.0
hooks:
Expand Down
8 changes: 6 additions & 2 deletions pyproject.toml
Expand Up @@ -23,11 +23,11 @@ classifiers = [
"Operating System :: POSIX :: Linux",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: System :: Systems Administration",
"Topic :: Utilities",
]
Expand All @@ -36,7 +36,7 @@ keywords = [
"rst",
"linter",
]
requires-python = ">=3.7"
requires-python = ">=3.8"
dependencies = [
# Ceiled due to DeprecationWarning: The frontend.OptionParser class will be
# replaced by a subclass of argparse.ArgumentParser in Docutils 0.21 or later.
Expand Down Expand Up @@ -71,13 +71,17 @@ filterwarnings = [
]

[[tool.mypy.overrides]]
python_version = "3.8"
module = [
"doc8._version",
"restructuredtext_lint",
"stevedore",
]
ignore_missing_imports = true

[tool.pylint.MAIN]
py-version = "3.8.0"

[tool.pylint."MESSAGES CONTROL"]

disable = [
Expand Down
3 changes: 1 addition & 2 deletions src/doc8/checks.py
Expand Up @@ -313,5 +313,4 @@ def report_iter(self, parsed_file):
checker_func = self._txt_checker
else:
checker_func = self._rst_checker
for issue in checker_func(parsed_file):
yield issue
yield from checker_func(parsed_file)
20 changes: 13 additions & 7 deletions src/doc8/main.py
Expand Up @@ -85,7 +85,7 @@ def parse_ignore_path_errors(entries):

def from_ini(fp):
parser = configparser.RawConfigParser()
with open(fp, "r", encoding="utf-8") as fh:
with open(fp, encoding="utf-8") as fh:
parser.read_file(fh)

cfg = {}
Expand Down Expand Up @@ -275,10 +275,14 @@ def validate(cfg, files, result=None):
line_num = "?"
if cfg.get("verbose"):
print(
" - %s:%s: %s %s" % (f.filename, line_num, code, message)
" - {}:{}: {} {}".format(
f.filename, line_num, code, message
)
)
elif not result.capture:
print("%s:%s: %s %s" % (f.filename, line_num, code, message))
print(
"{}:{}: {} {}".format(f.filename, line_num, code, message)
)
result.error(check_name, f.filename, line_num, code, message)
error_counts[check_name] += 1
elif isinstance(c, checks.LineCheck):
Expand All @@ -293,12 +297,14 @@ def validate(cfg, files, result=None):
)
elif not result.capture:
print(
"%s:%s: %s %s" % (f.filename, line_num, code, message)
"{}:{}: {} {}".format(
f.filename, line_num, code, message
)
)
result.error(check_name, f.filename, line_num, code, message)
error_counts[check_name] += 1
else:
raise TypeError("Unknown check type: %s, %s" % (type(c), c))
raise TypeError("Unknown check type: {}, {}".format(type(c), c))
return error_counts


Expand All @@ -321,7 +327,7 @@ def get_defaults():
}


class Result(object):
class Result:
def __init__(self):
self.files_selected = 0
self.files_ignored = 0
Expand Down Expand Up @@ -360,7 +366,7 @@ def report(self):
lines.append("Detailed error counts:")
for check_name in sorted(self.error_counts.keys()):
check_errors = self.error_counts[check_name]
lines.append(" - %s = %s" % (check_name, check_errors))
lines.append(" - {} = {}".format(check_name, check_errors))

return "\n".join(lines)

Expand Down
6 changes: 3 additions & 3 deletions src/doc8/parser.py
Expand Up @@ -22,7 +22,7 @@
import restructuredtext_lint as rl


class ParsedFile(object):
class ParsedFile:
FALLBACK_ENCODING = "utf-8"

def __init__(self, filename, encoding=None, default_extension=""):
Expand Down Expand Up @@ -127,7 +127,7 @@ def contents(self):
return self._content

def __str__(self):
return "%s (%s, %s chars, %s lines)" % (
return "{} ({}, {} chars, {} lines)".format(
self.filename,
self.encoding,
len(self.contents),
Expand All @@ -137,5 +137,5 @@ def __str__(self):

def parse(filename, encoding=None, default_extension=""):
if not os.path.isfile(filename):
raise IOError(errno.ENOENT, "File not found", filename)
raise OSError(errno.ENOENT, "File not found", filename)
return ParsedFile(filename, encoding=encoding, default_extension=default_extension)
2 changes: 0 additions & 2 deletions src/doc8/tests/test_checks.py
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

# Copyright (C) 2014 Yahoo! Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
Expand Down
8 changes: 3 additions & 5 deletions src/doc8/tests/test_main.py
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

import os
from io import StringIO
import unittest
Expand Down Expand Up @@ -79,7 +77,7 @@
- doc8.checks.CheckValidity = 0"""


class Capture(object):
class Capture:
"""
Context manager to capture output on stdout and stderr
"""
Expand All @@ -100,7 +98,7 @@ def __exit__(self, *args):
sys.stderr = self.err


class TmpFs(object):
class TmpFs:
"""
Context manager to create and clean a temporary file area for testing
"""
Expand Down Expand Up @@ -134,7 +132,7 @@ def expected(self, template):
return template.format(path=self.path)


class FakeResult(object):
class FakeResult:
"""
Minimum valid result returned from doc8
"""
Expand Down
2 changes: 1 addition & 1 deletion src/doc8/utils.py
Expand Up @@ -53,7 +53,7 @@ def path_ignorable(path):
if extension_matches(path):
yield (path, path_ignorable(path))
else:
raise IOError("Invalid path: %s" % path)
raise OSError("Invalid path: %s" % path)


def filtered_traverse(document, filter_func):
Expand Down
2 changes: 0 additions & 2 deletions src/doc8/version.py
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

# Copyright (C) 2014 Yahoo! Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
Expand Down