Skip to content

Commit 766020a

Browse files
Switched to pyproject; support collections.abc types
1 parent fd8d16c commit 766020a

File tree

9 files changed

+86
-84
lines changed

9 files changed

+86
-84
lines changed

.flake8

Lines changed: 0 additions & 4 deletions
This file was deleted.

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: [patrick-kidger]

.github/workflows/release.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Release
13+
uses: patrick-kidger/action_update_python_project@v2
14+
with:
15+
python-version: "3.11"
16+
test-script: ""
17+
pypi-token: ${{ secrets.pypi_token }}
18+
github-user: patrick-kidger
19+
github-token: ${{ github.token }}
20+
email-user: ${{ secrets.email_user }}
21+
email-token: ${{ secrets.email_token }}
22+
email-server: ${{ secrets.email_server }}
23+
email-target: ${{ secrets.email_target }}

.isort.cfg

Lines changed: 0 additions & 6 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ repos:
33
rev: 22.3.0
44
hooks:
55
- id: black
6-
- repo: https://github.com/PyCQA/isort
7-
rev: 5.10.1
6+
- repo: https://github.com/charliermarsh/ruff-pre-commit
7+
rev: 'v0.0.255'
88
hooks:
9-
- id: isort
10-
- repo: https://github.com/pycqa/flake8
11-
rev: 4.0.1
9+
- id: ruff
10+
args: ["--fix"]
11+
- repo: https://github.com/RobertCraigie/pyright-python
12+
rev: v1.1.314
1213
hooks:
13-
- id: flake8
14+
- id: pyright
15+
additional_dependencies: ["pytkdocs==0.15.0"]

MANIFEST.in

Lines changed: 0 additions & 1 deletion
This file was deleted.

pyproject.toml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
[project]
2+
name = "pytkdocs_tweaks"
3+
version = "0.0.7"
4+
description = "Some custom tweaks to the results produced by pytkdocs (part of mkdocstrings)."
5+
readme = "README.md"
6+
requires-python ="~=3.8"
7+
license = {file = "LICENSE"}
8+
authors = [
9+
{name = "Patrick Kidger", email = "[email protected]"},
10+
]
11+
keywords = ["documentation", "mkdocs", "mkdocs-material", "mkdocstrings"]
12+
classifiers = [
13+
"Development Status :: 3 - Alpha",
14+
"Intended Audience :: Developers",
15+
"License :: OSI Approved :: Apache Software License",
16+
"Natural Language :: English",
17+
"Programming Language :: Python :: 3",
18+
]
19+
urls = {repository = "https://github.com/patrick-kidger/pytkdocs_tweaks" }
20+
dependencies = ["pytkdocs>=0.15.0"]
21+
22+
[build-system]
23+
requires = ["hatchling"]
24+
build-backend = "hatchling.build"
25+
26+
[tool.hatch.build]
27+
include = ["pytkdocs_tweaks/*"]
28+
29+
[tool.ruff]
30+
select = ["E", "F", "I001"]
31+
ignore = ["E402", "E721", "E731", "E741", "F722"]
32+
ignore-init-module-imports = true
33+
fixable = ["I001", "F401"]
34+
35+
[tool.ruff.isort]
36+
combine-as-imports = true
37+
lines-after-imports = 2
38+
extra-standard-library = ["typing_extensions"]
39+
order-by-type = false
40+
41+
[tool.pyright]
42+
reportIncompatibleMethodOverride = true
43+
include = ["pytkdocs_tweaks"]

pytkdocs_tweaks/__init__.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import inspect
44
import json
55
import pathlib
6-
import sys
76
import traceback
87
import typing
98
import warnings
@@ -89,11 +88,17 @@ def _postprocess(data, cache, bases):
8988
parameter["annotation"] = parameter["annotation"].replace(
9089
p, p.rsplit(".", 1)[1]
9190
)
91+
parameter["annotation"] = parameter["annotation"].replace(
92+
"collections.abc.", ""
93+
)
9294
if "return_annotation" in signature:
9395
for p in cache:
9496
signature["return_annotation"] = signature["return_annotation"].replace(
9597
p, p.rsplit(".", 1)[1]
9698
)
99+
signature["return_annotation"] = signature["return_annotation"].replace(
100+
"collections.abc.", ""
101+
)
97102

98103
if "bases" in data:
99104
# Find those base classes which are part of our public documentation.
@@ -155,6 +160,7 @@ def _postprocess(data, cache, bases):
155160
if isinstance(_base_obj, property):
156161
# Property objects don't inherit module or qualname
157162
_base_obj = _base_obj.fget
163+
assert _base_obj is not None
158164
_base_path = _base_obj.__module__ + "." + _base_obj.__qualname__
159165
_base_config = {"objects": [{"path": _base_path}]}
160166
_base_result = pytkdocs.cli.process_config(_base_config)
@@ -250,8 +256,10 @@ def serialize_signature_parameter(parameter):
250256

251257
# By default pytkdocs has some really weird behaviour in which the docstring for
252258
# inherited magic methods are removed. This removes that behaviour.
253-
pytkdocs.loader.RE_SPECIAL = argparse.Namespace(match=lambda _: False)
259+
pytkdocs.loader.RE_SPECIAL = argparse.Namespace( # pyright: ignore
260+
match=lambda _: False
261+
)
254262

255263
# Set a flag to say we're generating documentation, which the library can use to
256264
# customise how its types are displayed.
257-
typing.GENERATING_DOCUMENTATION = True
265+
typing.GENERATING_DOCUMENTATION = True # pyright: ignore

setup.py

Lines changed: 0 additions & 64 deletions
This file was deleted.

0 commit comments

Comments
 (0)