Skip to content

Commit

Permalink
Merge pull request #474 from mitmproxy/pyproject.toml
Browse files Browse the repository at this point in the history
Switch to `pyproject.toml`
  • Loading branch information
mhils authored Dec 28, 2022
2 parents 4bb93ac + a7426ba commit 693c5d6
Show file tree
Hide file tree
Showing 10 changed files with 266 additions and 205 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: "monthly"
- package-ecosystem: pip
directory: "/"
schedule:
interval: "monthly"
20 changes: 2 additions & 18 deletions .github/workflows/autofix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,11 @@ jobs:
python-version-file: .github/python-version.txt

- run: pip install -r requirements-dev.txt
- run: pip install -e .
- run: pip install --no-deps -e .

- run: ruff --fix-only .
- run: black .

- name: Run pyupgrade
run: |
shopt -s globstar
pyupgrade --exit-zero-even-if-changed --py37-plus **/*.py
- name: Run reorder-python-imports
run: |
shopt -s globstar
reorder-python-imports --exit-zero-even-if-changed --py37-plus **/*.py
- name: Run yesqa
run: |
shopt -s globstar
yesqa **/*.py || true
- run: autoflake --in-place --remove-all-unused-imports -r .

- run: git checkout test/testdata/ pdoc/markdown2/
- run: test/test_snapshot.py

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version-file: .github/python-version.txt
python-version: '3.11'

# ADJUST THIS: install all dependencies (including pdoc)
- run: pip install -e .
Expand Down
68 changes: 44 additions & 24 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,16 @@ permissions:
contents: read

jobs:
lint-pr:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: TrueBrain/actions-flake8@9a43ff1b2c7b96f3edffc48a49973ce3de116ba1
lint-local:
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version-file: .github/python-version.txt
- run: pip install tox
- run: tox -e flake8
mypy:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version-file: .github/python-version.txt
- run: pip install tox
- run: tox -e mypy
- name: Install tox from PyPI
uses: install-pinned/tox@1bef451c18dcd629082d73fd4d7f57fdaa64ccf5 # 4.0.18
- run: tox -e lint
test:
strategy:
fail-fast: false
Expand Down Expand Up @@ -61,9 +46,30 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.py }}
- run: pip install tox
- name: Install tox from PyPI
uses: install-pinned/tox@1bef451c18dcd629082d73fd4d7f57fdaa64ccf5 # 4.0.18
- run: tox -e py -- -vvv ${{ matrix.args }}

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version-file: .github/python-version.txt
- name: Install build from PyPI
uses: install-pinned/build@7dc86bac5c289186da40e9ef255981d74ba7db4b # 0.9.0
- name: Install setuptools from PyPI
uses: install-pinned/setuptools@a3794bc223f37de1a371a34b64836a8c0c4f3167 # 65.6.3
- name: Install wheel from PyPI
uses: install-pinned/wheel@898673260e6f8eb95e3602c6a08907ca13670387 # 0.38.4

- run: sudo unshare --net -- $(which python) -m build --no-isolation
- uses: actions/upload-artifact@v3
with:
name: dist
path: dist/

deploy:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
environment: deploy
Expand All @@ -72,11 +78,25 @@ jobs:
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
TWINE_REPOSITORY: ${{ secrets.TWINE_REPOSITORY }}
runs-on: ubuntu-latest
needs: [mypy, test]
needs: [lint, test, build]
steps:
- uses: actions/checkout@v3
- run: sudo apt-get update
- run: sudo apt-get install -y twine python3-wheel
- run: python3 setup.py sdist bdist_wheel
- run: sudo apt-get install -y twine
- uses: actions/download-artifact@v3
with:
name: dist
path: dist/
- run: twine check dist/*
- run: twine upload dist/*

check:
if: always()
runs-on: ubuntu-latest
needs:
- lint
- test
- build
steps:
- uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2
with:
jobs: ${{ toJSON(needs) }}
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
graft pdoc
graft requirements
include CHANGELOG.md
include LICENSE
include README.md
Expand Down
8 changes: 7 additions & 1 deletion pdoc/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import pdoc.doc
import pdoc.docstrings
from pdoc._compat import Literal
from pdoc.render_helpers import DefaultMacroExtension
from pdoc.render_helpers import defuse_unsafe_reprs
from pdoc.render_helpers import edit_url
Expand All @@ -28,6 +27,13 @@
from pdoc.search import make_index
from pdoc.search import precompile_index

try:
from typing import Literal
except ImportError: # pragma: no cover
# Python < 3.8 - we cannot use pdoc._compat because ruff does not like it.
class Literal: # type: ignore
pass


def configure(
*,
Expand Down
121 changes: 121 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
[project]
name = "pdoc"
description = "API Documentation for Python Projects"
readme = "README.md"
requires-python = ">=3.7"
license = { text="Unlicense" }
authors = [{name = "Maximilian Hils", email = "pdoc@maximilianhils.com"}]
dynamic = ["version"]

dependencies = [
"Jinja2 >= 2.11.0",
"pygments >= 2.12.0",
"MarkupSafe",
"astunparse; python_version<'3.9'",
]

classifiers = [
"Topic :: Documentation",
"Topic :: Software Development :: Documentation",
"Topic :: Utilities",
"License :: Public Domain",
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Typing :: Typed",
]

[project.urls]
Homepage = "https://pdoc.dev"
Source = "https://github.com/mitmproxy/pdoc/"
Documentation = "https://pdoc.dev/docs/pdoc.html"
Issues = "https://github.com/mitmproxy/pdoc/issues"

[project.scripts]
pdoc = "pdoc.__main__:cli"

[project.optional-dependencies]
dev = [
"tox",
"ruff",
"black",
"mypy",
"types-pygments",
"pytest",
"pytest-cov",
"pytest-timeout",
"hypothesis",
]

[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[tool.setuptools.dynamic]
version = {attr = "pdoc.__version__"}

[tool.coverage.run]
branch = false
omit = [
"pdoc/markdown2/*",
]

# continue exclude: https://github.com/nedbat/coveragepy/issues/198
[tool.coverage.report]
show_missing = true
exclude_lines = [
"pragma: no cover",
"@overload",
"if TYPE_CHECKING:",
"pass",
"continue",
]

[tool.pytest.ini_options]
testpaths = "test"
addopts = "-p no:xdist"
timeout = 120
markers = [
"slow: marks tests as slow.",
]

[tool.black]
extend-exclude = "test/testdata/demo.py"

[[tool.mypy.overrides]]
module = "pytest.*"
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = "demopackage2"
ignore_missing_imports = true

[tool.ruff]
line-length = 140

[tool.tox]
legacy_tox_ini = """
[tox]
envlist = lint, py
skipsdist = True
toxworkdir = {env:TOX_WORK_DIR:.tox}
[testenv]
deps =
-r requirements-dev.txt
-e .
commands =
pdoc --version
pytest --cov=pdoc --cov-report term-missing {posargs:-m "not slow"}
[testenv:lint]
commands =
ruff . {posargs}
mypy pdoc test {posargs}
"""
Loading

0 comments on commit 693c5d6

Please sign in to comment.