Skip to content

Commit c39a973

Browse files
committed
Merge branch 'develop'
2 parents 86f830c + dbd9ac7 commit c39a973

Some content is hidden

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

56 files changed

+505
-516
lines changed

.github/FUNDING.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# These are supported funding model platforms
2+
# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/displaying-a-sponsor-button-in-your-repository
3+
4+
github: [andreoliwa] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
5+
# patreon: # Replace with a single Patreon username
6+
# open_collective: andreoliwa # Replace with a single Open Collective username
7+
ko_fi: andreoliwa # Replace with a single Ko-fi username
8+
# tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
9+
# community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
10+
liberapay: andreoliwa # Replace with a single Liberapay username
11+
# issuehunt: # Replace with a single IssueHunt username
12+
# otechie: # Replace with a single Otechie username
13+
# lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
14+
custom: ["https://www.paypal.me/andreoliwa", "https://www.buymeacoffee.com/andreoliwa"] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

.github/workflows/python.yaml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,26 @@
55

66
name: Python
77

8-
on: [push]
8+
on: [push, pull_request]
99

1010
jobs:
11+
# Adapted from https://github.com/marketplace/actions/skip-duplicate-actions
12+
pre_job:
13+
# continue-on-error: true # TODO: Uncomment once integration is finished
14+
runs-on: ubuntu-latest
15+
# Map a step output to a job output
16+
outputs:
17+
should_skip: ${{ steps.skip_check.outputs.should_skip }}
18+
steps:
19+
- id: skip_check
20+
uses: fkirc/skip-duplicate-actions@v5
21+
with:
22+
# https://github.com/marketplace/actions/skip-duplicate-actions#skip-concurrent-workflow-runs
23+
concurrent_skipping: "same_content_newer"
24+
1125
build:
26+
needs: pre_job
27+
if: needs.pre_job.outputs.should_skip != 'true'
1228
name: "${{ matrix.python-version }} ${{ matrix.os }}"
1329
strategy:
1430
fail-fast: false

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,6 @@ ENV/
116116

117117
# macOS
118118
.DS_Store
119+
120+
# pytest-testmon
121+
.testmondata*

.pre-commit-config.yaml

Lines changed: 8 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -39,32 +39,18 @@ repos:
3939
- id: debug-statements
4040
- id: end-of-file-fixer
4141
- id: trailing-whitespace
42-
- repo: https://github.com/asottile/pyupgrade
43-
rev: v3.3.1
42+
- repo: https://github.com/charliermarsh/ruff-pre-commit
43+
rev: v0.0.269
4444
hooks:
45-
- id: pyupgrade
46-
args: [--py37-plus]
45+
- id: ruff
46+
args: [--fix]
4747
- repo: https://github.com/aio-libs/sort-all # TODO: style(pre-commit): add sort-all
4848
rev: v1.2.0
4949
hooks:
5050
- id: sort-all
5151
language_version: python3.8
52-
- repo: https://github.com/PyCQA/autoflake
53-
rev: v2.0.2
54-
hooks:
55-
- id: autoflake
56-
args:
57-
[
58-
--in-place,
59-
--remove-all-unused-imports,
60-
--remove-unused-variables,
61-
--remove-duplicate-keys,
62-
--ignore-init-module-imports,
63-
--exclude,
64-
compat.py,
65-
]
6652
- repo: https://github.com/psf/black
67-
rev: 23.1.0
53+
rev: 23.3.0
6854
hooks:
6955
- id: black
7056
args: [--safe, --quiet]
@@ -73,46 +59,18 @@ repos:
7359
hooks:
7460
- id: blacken-docs
7561
additional_dependencies: [black==22.1.0]
76-
- repo: https://github.com/PyCQA/isort
77-
rev: 5.12.0
78-
hooks:
79-
- id: isort
80-
# To avoid ERROR: Package 'isort' requires a different Python: 3.7.12 not in '>=3.8.0'
81-
language_version: python3.8
8262
- repo: https://github.com/pre-commit/pygrep-hooks
8363
rev: v1.10.0
8464
hooks:
85-
- id: python-check-blanket-noqa
8665
- id: python-check-mock-methods
87-
- id: python-no-eval
88-
- id: python-no-log-warn
8966
- id: rst-backticks
9067
- repo: https://github.com/pre-commit/mirrors-prettier
91-
rev: v3.0.0-alpha.6
68+
rev: v3.0.0-alpha.9-for-vscode
9269
hooks:
9370
- id: prettier
9471
stages: [commit]
95-
- repo: https://github.com/PyCQA/flake8
96-
rev: 6.0.0
97-
hooks:
98-
- id: flake8
99-
language_version: python3.8
100-
additional_dependencies:
101-
[
102-
flake8-blind-except,
103-
flake8-bugbear,
104-
flake8-comprehensions,
105-
flake8-debugger,
106-
flake8-docstrings,
107-
flake8-isort,
108-
flake8-polyfill,
109-
flake8-pytest,
110-
flake8-quotes,
111-
flake8-typing-imports,
112-
yesqa,
113-
]
11472
- repo: https://github.com/pre-commit/mirrors-mypy
115-
rev: v1.1.1
73+
rev: v1.3.0
11674
hooks:
11775
- id: mypy
11876
# https://mypy.readthedocs.io/en/stable/command_line.html#cmdoption-mypy-show-error-codes
@@ -140,12 +98,6 @@ repos:
14098
language: system
14199
types: [python]
142100
exclude: tests/
143-
- repo: https://github.com/PyCQA/bandit
144-
rev: 1.7.5
145-
hooks:
146-
- id: bandit
147-
args: [--ini, setup.cfg]
148-
exclude: tests/
149101
- repo: https://github.com/shellcheck-py/shellcheck-py
150102
rev: v0.9.0.2
151103
hooks:
@@ -157,7 +109,7 @@ repos:
157109
# https://docs.openstack.org/bashate/latest/man/bashate.html#options
158110
args: [-i, E006]
159111
- repo: https://github.com/commitizen-tools/commitizen
160-
rev: v2.42.1
112+
rev: 3.2.2
161113
hooks:
162114
- id: commitizen
163115
stages: [commit-msg]

.tool-versions

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
poetry 1.4.1
2-
pre-commit 3.2.0
1+
poetry 1.5.0
2+
pre-commit 3.3.2

docs/autofix_docs.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
It doesn't recognise the "styles" dir anywhere (on the root, under "docs", under "_static"...).
88
Not even changing ``html_static_path`` on ``conf.py`` worked.
99
"""
10+
from __future__ import annotations
11+
1012
import sys
1113
from collections import defaultdict
1214
from importlib import import_module
1315
from pathlib import Path
1416
from subprocess import check_output # nosec
1517
from textwrap import dedent, indent
16-
from typing import Optional, Dict, List, Set, Tuple, Union
1718

1819
import attr
1920
import click
@@ -55,15 +56,16 @@ class FileType:
5556

5657
text: str
5758
url: str
58-
check: Union[bool, int]
59-
autofix: Union[bool, int]
59+
check: bool | int
60+
autofix: bool | int
6061

6162
def __post_init__(self):
6263
"""Warn about text that might render incorrectly."""
6364
if "`" in self.text:
64-
raise RuntimeError(f"Remove all backticks from the text: {self.text}")
65+
msg = f"Remove all backticks from the text: {self.text}"
66+
raise RuntimeError(msg)
6567

66-
def __lt__(self, other: "FileType") -> bool:
68+
def __lt__(self, other: FileType) -> bool:
6769
"""Sort instances.
6870
6971
From the `docs <https://docs.python.org/3/howto/sorting.html#odd-and-ends>`_:
@@ -103,12 +105,12 @@ def autofix_str(self) -> str:
103105
return self._pretty("autofix")
104106

105107
@property
106-
def row(self) -> Tuple[str, str, str]:
108+
def row(self) -> tuple[str, str, str]:
107109
"""Tuple for a table row."""
108110
return self.text_with_url, self.check_str, self.autofix_str
109111

110112

111-
IMPLEMENTED_FILE_TYPES: Set[FileType] = {
113+
IMPLEMENTED_FILE_TYPES: set[FileType] = {
112114
FileType("Any INI file", f"{READ_THE_DOCS_URL}plugins.html#ini-files", True, True),
113115
FileType("Any JSON file", f"{READ_THE_DOCS_URL}plugins.html#json-files", True, True),
114116
FileType("Any plain text file", f"{READ_THE_DOCS_URL}plugins.html#text-files", True, False),
@@ -118,7 +120,7 @@ def row(self) -> Tuple[str, str, str]:
118120
FileType(PYLINTRC, f"{READ_THE_DOCS_URL}plugins.html#ini-files", True, True),
119121
FileType(SETUP_CFG, f"{READ_THE_DOCS_URL}plugins.html#ini-files", True, True),
120122
}
121-
PLANNED_FILE_TYPES: Set[FileType] = {
123+
PLANNED_FILE_TYPES: set[FileType] = {
122124
FileType("Any Markdown file", "", 280, 0),
123125
FileType("Any Terraform file", "", 318, 0),
124126
FileType(".dockerignore", "", 8, 8),
@@ -145,7 +147,7 @@ def __init__(self, filename: str) -> None:
145147
self.divider_end = RST_DIVIDER_END
146148
self.divider_from_here = RST_DIVIDER_FROM_HERE
147149

148-
def write(self, lines: List[str], divider: Optional[str] = None) -> int:
150+
def write(self, lines: list[str], divider: str | None = None) -> int:
149151
"""Write content to the file."""
150152
old_content = self.file.read_text()
151153
if divider:
@@ -193,7 +195,6 @@ def write_plugins() -> int:
193195
):
194196
header = plugin_class.filename
195197
if not header:
196-
# module_name = file_class.__module__
197198
module = import_module(plugin_class.__module__)
198199
header = (module.__doc__ or "").strip(" .")
199200

@@ -234,7 +235,7 @@ def write_cli() -> int:
234235
parts.append(command)
235236
parts.append("--help")
236237
print(" ".join(parts))
237-
output = check_output(parts).decode().strip() # nosec
238+
output = check_output(parts).decode().strip() # noqa: S603
238239
blocks.append(
239240
clean_template.format(
240241
anchor=anchor, header=header, dashes="-" * len(header), long=dedent(long), help=indent(output, " ")
@@ -252,20 +253,20 @@ def write_config() -> int:
252253
return DocFile("configuration.rst").write(blocks, divider="config-file")
253254

254255

255-
def rst_table(header: Tuple[str, ...], rows: List[Tuple[str, ...]]) -> List[str]:
256+
def rst_table(header: tuple[str, ...], rows: list[tuple[str, ...]]) -> list[str]:
256257
"""Create a ReST table from header and rows."""
257258
blocks = [".. list-table::\n :header-rows: 1\n"]
258259
num_columns = len(header)
259-
for row in [header] + rows:
260+
for row in [header, *rows]:
260261
template = ("*" + " - {}\n " * num_columns).rstrip()
261262
blocks.append(indent(template.format(*row), " "))
262263
return blocks
263264

264265

265-
def write_readme(file_types: Set[FileType], divider: str) -> int:
266+
def write_readme(file_types: set[FileType], divider: str) -> int:
266267
"""Write the README."""
267268
# TODO: chore: quickstart.rst has some parts of README.rst as a copy/paste/change
268-
rows: List[Tuple[str, ...]] = []
269+
rows: list[tuple[str, ...]] = []
269270
for file_type in sorted(file_types):
270271
rows.append(file_type.row)
271272

@@ -281,9 +282,9 @@ class StyleLibraryRow: # pylint: disable=too-few-public-methods
281282
name: str
282283

283284

284-
def _build_library(gitref: bool = True) -> List[str]:
285+
def _build_library(gitref: bool = True) -> list[str]:
285286
# pylint: disable=no-member
286-
library: Dict[str, List[Tuple]] = defaultdict(list)
287+
library: dict[str, list[tuple]] = defaultdict(list)
287288
pre, post = (":gitref:", "") if gitref else ("", "_")
288289
for path in sorted(builtin_styles()): # type: Path
289290
style = BuiltinStyle.from_path(path)

docs/conf.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""
2-
Configuration file for the Sphinx documentation builder.
1+
"""Configuration file for the Sphinx documentation builder.
32
43
This file does only contain a selection of the most common options. For a
54
full list see the documentation:
@@ -15,7 +14,7 @@
1514

1615
# -- Project information -----------------------------------------------------
1716
project = "nitpick"
18-
copyright = "2019, W. Augusto Andreoli" # pylint: disable=redefined-builtin
17+
copyright = "2019, W. Augusto Andreoli" # pylint: disable=redefined-builtin # noqa: A001
1918
author = "W. Augusto Andreoli"
2019

2120
# The short X.Y version

docs/ideas/lab.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ def convert(path_from_root: str):
3333
if "yaml" in tags:
3434
which_doc = YamlDoc(path=path_from_root)
3535
else:
36-
raise NotImplementedError(f"No conversion for these types: {tags}")
36+
msg = f"No conversion for these types: {tags}"
37+
raise NotImplementedError(msg)
3738

3839
toml_doc = TomlDoc(obj={path_from_root: which_doc.as_object}, use_tomlkit=True)
3940
print(toml_doc.reformatted)

0 commit comments

Comments
 (0)