Skip to content

Commit 1782eeb

Browse files
authored
Changes to use black Python formatter (#1270)
1 parent c87933b commit 1782eeb

111 files changed

Lines changed: 14031 additions & 12734 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/lint.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Check source.
2+
name: lint
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
push:
8+
branches:
9+
- main
10+
permissions: read-all
11+
jobs:
12+
black:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v6
16+
- name: Check format of Python code
17+
uses: psf/black@stable
18+
with:
19+
options: "--check"
20+
src: "."
21+
pylint:
22+
runs-on: ubuntu-latest
23+
strategy:
24+
matrix:
25+
python-version: ['3.14']
26+
container:
27+
image: ubuntu:26.04
28+
steps:
29+
- uses: actions/checkout@v6
30+
- name: Set up container
31+
env:
32+
DEBIAN_FRONTEND: noninteractive
33+
run: |
34+
apt-get update -q
35+
apt-get install -y libterm-readline-gnu-perl locales software-properties-common
36+
locale-gen en_US.UTF-8
37+
ln -f -s /usr/share/zoneinfo/UTC /etc/localtime
38+
- name: Install dependencies
39+
env:
40+
DEBIAN_FRONTEND: noninteractive
41+
run: |
42+
add-apt-repository -y universe
43+
add-apt-repository -y ppa:deadsnakes/ppa
44+
add-apt-repository -y ppa:gift/dev
45+
apt-get update -q
46+
apt-get install -y build-essential git pkg-config python${{ matrix.python-version }} python${{ matrix.python-version }}-dev python${{ matrix.python-version }}-venv python3-pip python3-setuptools tox
47+
- name: Run linter
48+
env:
49+
LANG: en_US.UTF-8
50+
run: |
51+
tox -e pylint

.github/workflows/test_tox.yml

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -81,34 +81,3 @@ jobs:
8181
uses: codecov/codecov-action@v6
8282
with:
8383
token: ${{ secrets.CODECOV_TOKEN }}
84-
lint:
85-
runs-on: ubuntu-latest
86-
strategy:
87-
matrix:
88-
python-version: ['3.14']
89-
container:
90-
image: ubuntu:26.04
91-
steps:
92-
- uses: actions/checkout@v6
93-
- name: Set up container
94-
env:
95-
DEBIAN_FRONTEND: noninteractive
96-
run: |
97-
apt-get update -q
98-
apt-get install -y libterm-readline-gnu-perl locales software-properties-common
99-
locale-gen en_US.UTF-8
100-
ln -f -s /usr/share/zoneinfo/UTC /etc/localtime
101-
- name: Install dependencies
102-
env:
103-
DEBIAN_FRONTEND: noninteractive
104-
run: |
105-
add-apt-repository -y universe
106-
add-apt-repository -y ppa:deadsnakes/ppa
107-
add-apt-repository -y ppa:gift/dev
108-
apt-get update -q
109-
apt-get install -y build-essential git pkg-config python${{ matrix.python-version }} python${{ matrix.python-version }}-dev python${{ matrix.python-version }}-venv python3-pip python3-setuptools tox
110-
- name: Run linter
111-
env:
112-
LANG: en_US.UTF-8
113-
run: |
114-
tox -e lint

.pylintrc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,12 +358,11 @@ indent-after-paren=4
358358

359359
# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
360360
# tab).
361-
# indent-string=' '
362-
indent-string=' '
361+
indent-string=' '
363362

364363
# Maximum number of characters on a single line.
365364
# max-line-length=100
366-
max-line-length=80
365+
max-line-length=88
367366

368367
# Maximum number of lines in a module.
369368
max-module-lines=1000
@@ -599,7 +598,7 @@ spelling-store-unknown-words=no
599598

600599
# This flag controls whether inconsistent-quotes generates a warning when the
601600
# character used as a quote delimiter is used inconsistently within a module.
602-
check-quote-consistency=no
601+
check-quote-consistency=yes
603602

604603
# This flag controls whether the implicit-str-concat should generate a warning
605604
# on implicit string concatenation in sequences defined over several lines.

data/rpm_templates/zstd.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Group: Development/Libraries
1212
Prefix: %{{_prefix}}
1313
Vendor: Sergey Dryabzhinsky <sergey.dryabzhinsky@gmail.com>
1414
Url: https://github.com/sergey-dryabzhinsky/python-zstd
15-
BuildRequires: gcc, python3-devel, python3-setuptools
15+
BuildRequires: gcc, python3-devel, python3-pip, python3-setuptools
1616

1717
%description
1818
Python bindings to Yann Collet ZSTD compression library.

data/templates/.pylintrc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,12 +358,11 @@ indent-after-paren=4
358358

359359
# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
360360
# tab).
361-
# indent-string=' '
362-
indent-string=' '
361+
indent-string=' '
363362

364363
# Maximum number of characters on a single line.
365364
# max-line-length=100
366-
max-line-length=80
365+
max-line-length=88
367366

368367
# Maximum number of lines in a module.
369368
max-module-lines=1000
@@ -599,7 +598,7 @@ spelling-store-unknown-words=no
599598

600599
# This flag controls whether inconsistent-quotes generates a warning when the
601600
# character used as a quote delimiter is used inconsistently within a module.
602-
check-quote-consistency=no
601+
check-quote-consistency=yes
603602

604603
# This flag controls whether the implicit-str-concat should generate a warning
605604
# on implicit string concatenation in sequences defined over several lines.

data/templates/check_dependencies.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
import sys
55

66
# Change PYTHONPATH to include dependencies.
7-
sys.path.insert(0, '.')
7+
sys.path.insert(0, ".")
88

99
import utils.dependencies # pylint: disable=wrong-import-position
1010

11+
if __name__ == "__main__":
12+
dependency_helper = utils.dependencies.DependencyHelper()
1113

12-
if __name__ == '__main__':
13-
dependency_helper = utils.dependencies.DependencyHelper()
14-
15-
if not dependency_helper.CheckDependencies():
16-
sys.exit(1)
14+
if not dependency_helper.CheckDependencies():
15+
sys.exit(1)

data/templates/docs/conf.py

Lines changed: 73 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,39 @@
99
from docutils import transforms
1010

1111
# Change PYTHONPATH to include ${python_module_name} module and dependencies.
12-
sys.path.insert(0, os.path.abspath('..'))
12+
sys.path.insert(0, os.path.abspath(".."))
1313

1414
import ${python_module_name} # pylint: disable=wrong-import-position
1515

1616
import utils.dependencies # pylint: disable=wrong-import-position
1717

18-
1918
# -- General configuration ------------------------------------------------
2019

2120
# If your documentation needs a minimal Sphinx version, state it here.
22-
needs_sphinx = '2.0.1'
21+
needs_sphinx = "2.0.1"
2322

2423
# Add any Sphinx extension module names here, as strings. They can be
2524
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
2625
# ones.
2726
extensions = [
28-
'recommonmark',
29-
'sphinx.ext.autodoc',
30-
'sphinx.ext.coverage',
31-
'sphinx.ext.doctest',
32-
'sphinx.ext.napoleon',
33-
'sphinx.ext.viewcode',
34-
'sphinx_markdown_tables',
35-
'sphinx_rtd_theme',
27+
"recommonmark",
28+
"sphinx.ext.autodoc",
29+
"sphinx.ext.coverage",
30+
"sphinx.ext.doctest",
31+
"sphinx.ext.napoleon",
32+
"sphinx.ext.viewcode",
33+
"sphinx_markdown_tables",
34+
"sphinx_rtd_theme",
3635
]
3736

3837
# We cannot install architecture dependent Python modules on readthedocs,
3938
# therefore we mock most imports.
4039
pip_installed_modules = set()
4140

4241
dependency_helper = utils.dependencies.DependencyHelper(
43-
dependencies_file=os.path.join('..', 'dependencies.ini'),
44-
test_dependencies_file=os.path.join('..', 'test_dependencies.ini'))
42+
dependencies_file=os.path.join("..", "dependencies.ini"),
43+
test_dependencies_file=os.path.join("..", "test_dependencies.ini"),
44+
)
4545
modules_to_mock = set(dependency_helper.dependencies.keys())
4646
modules_to_mock = modules_to_mock.difference(pip_installed_modules)
4747

@@ -57,114 +57,113 @@
5757

5858
# General information about the project.
5959
# pylint: disable=redefined-builtin
60-
project = '${name_description}'
61-
copyright = 'The ${name_description} authors'
60+
project = "${name_description}"
61+
copyright = "The ${name_description} authors"
6262
version = ${python_module_name}.__version__
6363
release = ${python_module_name}.__version__
6464

6565
# Add any paths that contain templates here, relative to this directory.
66-
templates_path = ['_templates']
66+
templates_path = ["_templates"]
6767

6868
# List of patterns, relative to source directory, that match files and
6969
# directories to ignore when looking for source files.
70-
exclude_patterns = ['_build']
70+
exclude_patterns = ["_build"]
7171

7272
# The master toctree document.
73-
master_doc = 'index'
73+
master_doc = "index"
7474

7575
# The name of the Pygments (syntax highlighting) style to use.
76-
pygments_style = 'sphinx'
76+
pygments_style = "sphinx"
7777

7878

7979
# -- Options for HTML output ----------------------------------------------
8080

8181
# The theme to use for HTML and HTML Help pages. See the documentation for
8282
# a list of builtin themes.
83-
html_theme = 'sphinx_rtd_theme'
83+
html_theme = "sphinx_rtd_theme"
8484

8585
# Output file base name for HTML help builder.
86-
htmlhelp_basename = '${htmlhelp_basename}doc'
86+
htmlhelp_basename = "${htmlhelp_basename}doc"
8787

8888

8989
# -- Options linkcheck ----------------------------------------------------
9090

91-
linkcheck_ignore = [
92-
]
91+
linkcheck_ignore = []
9392

9493

9594
# -- Code to rewrite links for readthedocs --------------------------------
9695

9796
# This function is a Sphinx core event callback, the format of which is detailed
9897
# here: https://www.sphinx-doc.org/en/master/extdev/appapi.html#events
9998

99+
100100
# pylint: disable=unused-argument
101101
def RunSphinxAPIDoc(app):
102-
"""Runs sphinx-apidoc to auto-generate documentation.
102+
"""Runs sphinx-apidoc to auto-generate documentation.
103103
104-
Args:
105-
app (sphinx.application.Sphinx): Sphinx application. Required by the
106-
the Sphinx event callback API.
107-
"""
108-
current_directory = os.path.abspath(os.path.dirname(__file__))
109-
module_path = os.path.join(current_directory, '..', '${python_module_name}')
110-
api_directory = os.path.join(current_directory, 'sources', 'api')
111-
apidoc.main(['-o', api_directory, module_path, '--force'])
104+
Args:
105+
app (sphinx.application.Sphinx): Sphinx application. Required by the
106+
the Sphinx event callback API.
107+
"""
108+
current_directory = os.path.abspath(os.path.dirname(__file__))
109+
module_path = os.path.join(current_directory, "..", "${python_module_name}")
110+
api_directory = os.path.join(current_directory, "sources", "api")
111+
apidoc.main(["-o", api_directory, module_path, "--force"])
112112

113113

114114
class MarkdownLinkFixer(transforms.Transform):
115-
"""Transform definition to parse .md references to internal pages."""
115+
"""Transform definition to parse .md references to internal pages."""
116116

117-
default_priority = 1000
117+
default_priority = 1000
118118

119-
_URI_PREFIXES = []
119+
_URI_PREFIXES = []
120120

121-
def _FixLinks(self, node):
122-
"""Corrects links to .md files not part of the documentation.
121+
def _FixLinks(self, node):
122+
"""Corrects links to .md files not part of the documentation.
123123
124-
Args:
125-
node (docutils.nodes.Node): docutils node.
124+
Args:
125+
node (docutils.nodes.Node): docutils node.
126126
127-
Returns:
128-
docutils.nodes.Node: docutils node, with correct URIs outside
129-
of Markdown pages outside the documentation.
130-
"""
131-
if isinstance(node, nodes.reference) and 'refuri' in node:
132-
reference_uri = node['refuri']
133-
for uri_prefix in self._URI_PREFIXES:
134-
if (reference_uri.startswith(uri_prefix) and not (
135-
reference_uri.endswith('.asciidoc') or
136-
reference_uri.endswith('.md'))):
137-
node['refuri'] = reference_uri + '.md'
138-
break
127+
Returns:
128+
docutils.nodes.Node: docutils node, with correct URIs outside
129+
of Markdown pages outside the documentation.
130+
"""
131+
if isinstance(node, nodes.reference) and "refuri" in node:
132+
reference_uri = node["refuri"]
133+
for uri_prefix in self._URI_PREFIXES:
134+
if reference_uri.startswith(uri_prefix) and not (
135+
reference_uri.endswith(".asciidoc") or reference_uri.endswith(".md")
136+
):
137+
node["refuri"] = reference_uri + ".md"
138+
break
139139

140-
return node
140+
return node
141141

142-
def _Traverse(self, node):
143-
"""Traverses the document tree rooted at node.
142+
def _Traverse(self, node):
143+
"""Traverses the document tree rooted at node.
144144
145-
Args:
146-
node (docutils.nodes.Node): docutils node.
147-
"""
148-
self._FixLinks(node)
145+
Args:
146+
node (docutils.nodes.Node): docutils node.
147+
"""
148+
self._FixLinks(node)
149149

150-
for child_node in node.children:
151-
self._Traverse(child_node)
150+
for child_node in node.children:
151+
self._Traverse(child_node)
152152

153-
# pylint: disable=arguments-differ
154-
def apply(self):
155-
"""Applies this transform on document tree."""
156-
self._Traverse(self.document)
153+
# pylint: disable=arguments-differ
154+
def apply(self):
155+
"""Applies this transform on document tree."""
156+
self._Traverse(self.document)
157157

158158

159159
# pylint: invalid-name
160160
def setup(app):
161-
"""Called at Sphinx initialization.
162-
163-
Args:
164-
app (sphinx.application.Sphinx): Sphinx application.
165-
"""
166-
# Triggers sphinx-apidoc to generate API documentation.
167-
app.connect('builder-inited', RunSphinxAPIDoc)
168-
app.add_config_value(
169-
'recommonmark_config', {'enable_auto_toc_tree': True}, True)
170-
app.add_transform(MarkdownLinkFixer)
161+
"""Called at Sphinx initialization.
162+
163+
Args:
164+
app (sphinx.application.Sphinx): Sphinx application.
165+
"""
166+
# Triggers sphinx-apidoc to generate API documentation.
167+
app.connect("builder-inited", RunSphinxAPIDoc)
168+
app.add_config_value("recommonmark_config", {"enable_auto_toc_tree": True}, True)
169+
app.add_transform(MarkdownLinkFixer)

0 commit comments

Comments
 (0)