Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Check source.
name: lint
on:
pull_request:
branches:
- main
push:
branches:
- main
permissions: read-all
jobs:
black:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Check format of Python code
uses: psf/black@stable
with:
options: "--check"
src: "."
pylint:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.14']
container:
image: ubuntu:26.04
steps:
- uses: actions/checkout@v6
- name: Set up container
env:
DEBIAN_FRONTEND: noninteractive
run: |
apt-get update -q
apt-get install -y libterm-readline-gnu-perl locales software-properties-common
locale-gen en_US.UTF-8
ln -f -s /usr/share/zoneinfo/UTC /etc/localtime
- name: Install dependencies
env:
DEBIAN_FRONTEND: noninteractive
run: |
add-apt-repository -y universe
add-apt-repository -y ppa:deadsnakes/ppa
add-apt-repository -y ppa:gift/dev
apt-get update -q
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
- name: Run linter
env:
LANG: en_US.UTF-8
run: |
tox -e pylint
31 changes: 0 additions & 31 deletions .github/workflows/test_tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,34 +81,3 @@ jobs:
uses: codecov/codecov-action@v6
with:
token: ${{ secrets.CODECOV_TOKEN }}
lint:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.14']
container:
image: ubuntu:26.04
steps:
- uses: actions/checkout@v6
- name: Set up container
env:
DEBIAN_FRONTEND: noninteractive
run: |
apt-get update -q
apt-get install -y libterm-readline-gnu-perl locales software-properties-common
locale-gen en_US.UTF-8
ln -f -s /usr/share/zoneinfo/UTC /etc/localtime
- name: Install dependencies
env:
DEBIAN_FRONTEND: noninteractive
run: |
add-apt-repository -y universe
add-apt-repository -y ppa:deadsnakes/ppa
add-apt-repository -y ppa:gift/dev
apt-get update -q
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
- name: Run linter
env:
LANG: en_US.UTF-8
run: |
tox -e lint
7 changes: 3 additions & 4 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,11 @@ indent-after-paren=4

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

# Maximum number of characters on a single line.
# max-line-length=100
max-line-length=80
max-line-length=88

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

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

# This flag controls whether the implicit-str-concat should generate a warning
# on implicit string concatenation in sequences defined over several lines.
Expand Down
2 changes: 1 addition & 1 deletion data/rpm_templates/zstd.spec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Group: Development/Libraries
Prefix: %{{_prefix}}
Vendor: Sergey Dryabzhinsky <sergey.dryabzhinsky@gmail.com>
Url: https://github.com/sergey-dryabzhinsky/python-zstd
BuildRequires: gcc, python3-devel, python3-setuptools
BuildRequires: gcc, python3-devel, python3-pip, python3-setuptools

%description
Python bindings to Yann Collet ZSTD compression library.
Expand Down
7 changes: 3 additions & 4 deletions data/templates/.pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,11 @@ indent-after-paren=4

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

# Maximum number of characters on a single line.
# max-line-length=100
max-line-length=80
max-line-length=88

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

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

# This flag controls whether the implicit-str-concat should generate a warning
# on implicit string concatenation in sequences defined over several lines.
Expand Down
11 changes: 5 additions & 6 deletions data/templates/check_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
import sys

# Change PYTHONPATH to include dependencies.
sys.path.insert(0, '.')
sys.path.insert(0, ".")

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

if __name__ == "__main__":
dependency_helper = utils.dependencies.DependencyHelper()

if __name__ == '__main__':
dependency_helper = utils.dependencies.DependencyHelper()

if not dependency_helper.CheckDependencies():
sys.exit(1)
if not dependency_helper.CheckDependencies():
sys.exit(1)
147 changes: 73 additions & 74 deletions data/templates/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,39 @@
from docutils import transforms

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

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

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


# -- General configuration ------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
needs_sphinx = '2.0.1'
needs_sphinx = "2.0.1"

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'recommonmark',
'sphinx.ext.autodoc',
'sphinx.ext.coverage',
'sphinx.ext.doctest',
'sphinx.ext.napoleon',
'sphinx.ext.viewcode',
'sphinx_markdown_tables',
'sphinx_rtd_theme',
"recommonmark",
"sphinx.ext.autodoc",
"sphinx.ext.coverage",
"sphinx.ext.doctest",
"sphinx.ext.napoleon",
"sphinx.ext.viewcode",
"sphinx_markdown_tables",
"sphinx_rtd_theme",
]

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

dependency_helper = utils.dependencies.DependencyHelper(
dependencies_file=os.path.join('..', 'dependencies.ini'),
test_dependencies_file=os.path.join('..', 'test_dependencies.ini'))
dependencies_file=os.path.join("..", "dependencies.ini"),
test_dependencies_file=os.path.join("..", "test_dependencies.ini"),
)
modules_to_mock = set(dependency_helper.dependencies.keys())
modules_to_mock = modules_to_mock.difference(pip_installed_modules)

Expand All @@ -57,114 +57,113 @@

# General information about the project.
# pylint: disable=redefined-builtin
project = '${name_description}'
copyright = 'The ${name_description} authors'
project = "${name_description}"
copyright = "The ${name_description} authors"
version = ${python_module_name}.__version__
release = ${python_module_name}.__version__

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

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

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"


# -- Options for HTML output ----------------------------------------------

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

# Output file base name for HTML help builder.
htmlhelp_basename = '${htmlhelp_basename}doc'
htmlhelp_basename = "${htmlhelp_basename}doc"


# -- Options linkcheck ----------------------------------------------------

linkcheck_ignore = [
]
linkcheck_ignore = []


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

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


# pylint: disable=unused-argument
def RunSphinxAPIDoc(app):
"""Runs sphinx-apidoc to auto-generate documentation.
"""Runs sphinx-apidoc to auto-generate documentation.

Args:
app (sphinx.application.Sphinx): Sphinx application. Required by the
the Sphinx event callback API.
"""
current_directory = os.path.abspath(os.path.dirname(__file__))
module_path = os.path.join(current_directory, '..', '${python_module_name}')
api_directory = os.path.join(current_directory, 'sources', 'api')
apidoc.main(['-o', api_directory, module_path, '--force'])
Args:
app (sphinx.application.Sphinx): Sphinx application. Required by the
the Sphinx event callback API.
"""
current_directory = os.path.abspath(os.path.dirname(__file__))
module_path = os.path.join(current_directory, "..", "${python_module_name}")
api_directory = os.path.join(current_directory, "sources", "api")
apidoc.main(["-o", api_directory, module_path, "--force"])


class MarkdownLinkFixer(transforms.Transform):
"""Transform definition to parse .md references to internal pages."""
"""Transform definition to parse .md references to internal pages."""

default_priority = 1000
default_priority = 1000

_URI_PREFIXES = []
_URI_PREFIXES = []

def _FixLinks(self, node):
"""Corrects links to .md files not part of the documentation.
def _FixLinks(self, node):
"""Corrects links to .md files not part of the documentation.

Args:
node (docutils.nodes.Node): docutils node.
Args:
node (docutils.nodes.Node): docutils node.

Returns:
docutils.nodes.Node: docutils node, with correct URIs outside
of Markdown pages outside the documentation.
"""
if isinstance(node, nodes.reference) and 'refuri' in node:
reference_uri = node['refuri']
for uri_prefix in self._URI_PREFIXES:
if (reference_uri.startswith(uri_prefix) and not (
reference_uri.endswith('.asciidoc') or
reference_uri.endswith('.md'))):
node['refuri'] = reference_uri + '.md'
break
Returns:
docutils.nodes.Node: docutils node, with correct URIs outside
of Markdown pages outside the documentation.
"""
if isinstance(node, nodes.reference) and "refuri" in node:
reference_uri = node["refuri"]
for uri_prefix in self._URI_PREFIXES:
if reference_uri.startswith(uri_prefix) and not (
reference_uri.endswith(".asciidoc") or reference_uri.endswith(".md")
):
node["refuri"] = reference_uri + ".md"
break

return node
return node

def _Traverse(self, node):
"""Traverses the document tree rooted at node.
def _Traverse(self, node):
"""Traverses the document tree rooted at node.

Args:
node (docutils.nodes.Node): docutils node.
"""
self._FixLinks(node)
Args:
node (docutils.nodes.Node): docutils node.
"""
self._FixLinks(node)

for child_node in node.children:
self._Traverse(child_node)
for child_node in node.children:
self._Traverse(child_node)

# pylint: disable=arguments-differ
def apply(self):
"""Applies this transform on document tree."""
self._Traverse(self.document)
# pylint: disable=arguments-differ
def apply(self):
"""Applies this transform on document tree."""
self._Traverse(self.document)


# pylint: invalid-name
def setup(app):
"""Called at Sphinx initialization.

Args:
app (sphinx.application.Sphinx): Sphinx application.
"""
# Triggers sphinx-apidoc to generate API documentation.
app.connect('builder-inited', RunSphinxAPIDoc)
app.add_config_value(
'recommonmark_config', {'enable_auto_toc_tree': True}, True)
app.add_transform(MarkdownLinkFixer)
"""Called at Sphinx initialization.

Args:
app (sphinx.application.Sphinx): Sphinx application.
"""
# Triggers sphinx-apidoc to generate API documentation.
app.connect("builder-inited", RunSphinxAPIDoc)
app.add_config_value("recommonmark_config", {"enable_auto_toc_tree": True}, True)
app.add_transform(MarkdownLinkFixer)
Loading
Loading