Skip to content

Commit

Permalink
Switched to pyproject; support collections.abc types
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-kidger committed Jun 14, 2023
1 parent fd8d16c commit 766020a
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 84 deletions.
4 changes: 0 additions & 4 deletions .flake8

This file was deleted.

1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: [patrick-kidger]
23 changes: 23 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Release

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Release
uses: patrick-kidger/action_update_python_project@v2
with:
python-version: "3.11"
test-script: ""
pypi-token: ${{ secrets.pypi_token }}
github-user: patrick-kidger
github-token: ${{ github.token }}
email-user: ${{ secrets.email_user }}
email-token: ${{ secrets.email_token }}
email-server: ${{ secrets.email_server }}
email-target: ${{ secrets.email_target }}
6 changes: 0 additions & 6 deletions .isort.cfg

This file was deleted.

14 changes: 8 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ repos:
rev: 22.3.0
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.255'
hooks:
- id: isort
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
- id: ruff
args: ["--fix"]
- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.314
hooks:
- id: flake8
- id: pyright
additional_dependencies: ["pytkdocs==0.15.0"]
1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

43 changes: 43 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[project]
name = "pytkdocs_tweaks"
version = "0.0.7"
description = "Some custom tweaks to the results produced by pytkdocs (part of mkdocstrings)."
readme = "README.md"
requires-python ="~=3.8"
license = {file = "LICENSE"}
authors = [
{name = "Patrick Kidger", email = "contact@kidger.site"},
]
keywords = ["documentation", "mkdocs", "mkdocs-material", "mkdocstrings"]
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Natural Language :: English",
"Programming Language :: Python :: 3",
]
urls = {repository = "https://github.com/patrick-kidger/pytkdocs_tweaks" }
dependencies = ["pytkdocs>=0.15.0"]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.build]
include = ["pytkdocs_tweaks/*"]

[tool.ruff]
select = ["E", "F", "I001"]
ignore = ["E402", "E721", "E731", "E741", "F722"]
ignore-init-module-imports = true
fixable = ["I001", "F401"]

[tool.ruff.isort]
combine-as-imports = true
lines-after-imports = 2
extra-standard-library = ["typing_extensions"]
order-by-type = false

[tool.pyright]
reportIncompatibleMethodOverride = true
include = ["pytkdocs_tweaks"]
14 changes: 11 additions & 3 deletions pytkdocs_tweaks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import inspect
import json
import pathlib
import sys
import traceback
import typing
import warnings
Expand Down Expand Up @@ -89,11 +88,17 @@ def _postprocess(data, cache, bases):
parameter["annotation"] = parameter["annotation"].replace(
p, p.rsplit(".", 1)[1]
)
parameter["annotation"] = parameter["annotation"].replace(
"collections.abc.", ""
)
if "return_annotation" in signature:
for p in cache:
signature["return_annotation"] = signature["return_annotation"].replace(
p, p.rsplit(".", 1)[1]
)
signature["return_annotation"] = signature["return_annotation"].replace(
"collections.abc.", ""
)

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

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

# Set a flag to say we're generating documentation, which the library can use to
# customise how its types are displayed.
typing.GENERATING_DOCUMENTATION = True
typing.GENERATING_DOCUMENTATION = True # pyright: ignore
64 changes: 0 additions & 64 deletions setup.py

This file was deleted.

0 comments on commit 766020a

Please sign in to comment.