diff --git a/.copier-answers.yml b/.copier-answers.yml
index 97027f2b..8cacdedb 100644
--- a/.copier-answers.yml
+++ b/.copier-answers.yml
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier
-_commit: 0.9.7
+_commit: 0.10.6
_src_path: gh:pawamoy/copier-pdm
author_email: pawamoy@pm.me
author_fullname: Timothée Mazzucotelli
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 201e8d52..287efc83 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -25,27 +25,13 @@ jobs:
steps:
- name: Checkout
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
- name: Set up PDM
- uses: pdm-project/setup-pdm@v2.6
+ uses: pdm-project/setup-pdm@v3
with:
python-version: "3.8"
- - name: Set cache variables
- id: set_variables
- run: |
- echo "::set-output name=PIP_CACHE::$(pip cache dir)"
- echo "::set-output name=PDM_CACHE::$(pdm config cache_dir)"
-
- - name: Set up cache
- uses: actions/cache@v2
- with:
- path: |
- ${{ steps.set_variables.outputs.PIP_CACHE }}
- ${{ steps.set_variables.outputs.PDM_CACHE }}
- key: checks-cache
-
- name: Resolving dependencies
run: pdm lock
@@ -77,33 +63,19 @@ jobs:
- "3.8"
- "3.9"
- "3.10"
- - "3.11-dev"
+ - "3.11"
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
- name: Set up PDM
- uses: pdm-project/setup-pdm@v2.6
+ uses: pdm-project/setup-pdm@v3
with:
python-version: ${{ matrix.python-version }}
- - name: Set cache variables
- id: set_variables
- run: |
- echo "::set-output name=PIP_CACHE::$(pip cache dir)"
- echo "::set-output name=PDM_CACHE::$(pdm config cache_dir)"
-
- - name: Set up cache
- uses: actions/cache@v2
- with:
- path: |
- ${{ steps.set_variables.outputs.PIP_CACHE }}
- ${{ steps.set_variables.outputs.PDM_CACHE }}
- key: tests-cache-${{ runner.os }}-${{ matrix.python-version }}
-
- name: Install dependencies
run: pdm install --no-editable -G duty -G tests
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 379d6671..b7389238 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,17 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
+## [0.8.0](https://github.com/mkdocstrings/python/releases/tag/0.8.0) - 2022-11-13
+
+[Compare with 0.7.1](https://github.com/mkdocstrings/python/compare/0.7.1...0.8.0)
+
+### Features
+- Add support for globs in paths configuration ([29edd02](https://github.com/mkdocstrings/python/commit/29edd02e7a4d83f6b7e8555d4d5b03a79882eb07) by Andrew Guenther). [Issue #33](https://github.com/mkdocstrings/python/issues/33), [PR #34](https://github.com/mkdocstrings/python/pull/34)
+
+### Code Refactoring
+- Support Griffe 0.24 ([3b9f701](https://github.com/mkdocstrings/python/commit/3b9f7013a7367f18e4354c37f029f9caf3ad0a4e) by Timothée Mazzucotelli).
+
+
## [0.7.1](https://github.com/mkdocstrings/python/releases/tag/0.7.1) - 2022-06-12
[Compare with 0.7.0](https://github.com/mkdocstrings/python/compare/0.7.0...0.7.1)
diff --git a/config/mypy.ini b/config/mypy.ini
index 814e2ac8..cb0dd886 100644
--- a/config/mypy.ini
+++ b/config/mypy.ini
@@ -3,3 +3,5 @@ ignore_missing_imports = true
exclude = tests/fixtures/
warn_unused_ignores = true
show_error_codes = true
+namespace_packages = true
+explicit_package_bases = true
diff --git a/docs/gen_ref_nav.py b/docs/gen_ref_nav.py
index 1b9fbda1..14f0f4ad 100755
--- a/docs/gen_ref_nav.py
+++ b/docs/gen_ref_nav.py
@@ -26,7 +26,7 @@
ident = ".".join(parts)
fd.write(f"::: {ident}")
- mkdocs_gen_files.set_edit_path(full_doc_path, path)
+ mkdocs_gen_files.set_edit_path(full_doc_path, ".." / path)
with mkdocs_gen_files.open("reference/SUMMARY.md", "w") as nav_file:
nav_file.writelines(nav.build_literate_nav())
diff --git a/duties.py b/duties.py
index 3ad804dd..1b64bcda 100644
--- a/duties.py
+++ b/duties.py
@@ -4,8 +4,6 @@
import os
import re
import sys
-import tempfile
-from contextlib import suppress
from io import StringIO
from pathlib import Path
from typing import List, Optional, Pattern
@@ -145,7 +143,8 @@ def check_dependencies(ctx):
importlib.invalidate_caches()
# reload original, unpatched safety
- from safety.formatter import report
+ from safety.formatter import SafetyFormatter
+ from safety.safety import calculate_remediations
from safety.safety import check as safety_check
from safety.util import read_requirements
@@ -159,10 +158,19 @@ def check_dependencies(ctx):
# check using safety as a library
def safety(): # noqa: WPS430
packages = list(read_requirements(StringIO(requirements)))
- vulns = safety_check(packages=packages, ignore_ids="", key="", db_mirror="", cached=False, proxy={})
- output_report = report(vulns=vulns, full=True, checked_packages=len(packages))
+ vulns, db_full = safety_check(packages=packages, ignore_vulns="")
+ remediations = calculate_remediations(vulns, db_full)
+ output_report = SafetyFormatter("text").render_vulnerabilities(
+ announcements=[],
+ vulnerabilities=vulns,
+ remediations=remediations,
+ full=True,
+ packages=packages,
+ )
if vulns:
print(output_report)
+ return False
+ return True
ctx.run(safety, title="Checking dependencies")
@@ -188,49 +196,8 @@ def check_types(ctx): # noqa: WPS231
Arguments:
ctx: The context instance (passed automatically).
"""
- # NOTE: the following code works around this issue:
- # https://github.com/python/mypy/issues/10633
-
- # compute packages directory path
- py = f"{sys.version_info.major}.{sys.version_info.minor}"
- pkgs_dir = Path("__pypackages__", py, "lib").resolve()
-
- # build the list of available packages
- packages = {}
- for package in pkgs_dir.glob("*"):
- if package.suffix not in {".dist-info", ".pth"} and package.name != "__pycache__":
- packages[package.name] = package
-
- # handle .pth files
- for pth in pkgs_dir.glob("*.pth"):
- with suppress(OSError):
- for package in Path(pth.read_text().splitlines()[0]).glob("*"): # noqa: WPS440
- if package.suffix != ".dist-info":
- packages[package.name] = package
-
- # create a temporary directory to assign to MYPYPATH
- with tempfile.TemporaryDirectory() as tmpdir:
-
- # symlink the stubs
- ignore = set()
- for stubs in (path for name, path in packages.items() if name.endswith("-stubs")): # noqa: WPS335
- Path(tmpdir, stubs.name).symlink_to(stubs, target_is_directory=True)
- # try to symlink the corresponding package
- # see https://www.python.org/dev/peps/pep-0561/#stub-only-packages
- pkg_name = stubs.name.replace("-stubs", "")
- if pkg_name in packages:
- ignore.add(pkg_name)
- Path(tmpdir, pkg_name).symlink_to(packages[pkg_name], target_is_directory=True)
-
- # create temporary mypy config to ignore stubbed packages
- newconfig = Path("config", "mypy.ini").read_text()
- newconfig += "\n" + "\n\n".join(f"[mypy-{pkg}.*]\nignore_errors=true" for pkg in ignore)
- tmpconfig = Path(tmpdir, "mypy.ini")
- tmpconfig.write_text(newconfig)
-
- # set MYPYPATH and run mypy
- os.environ["MYPYPATH"] = tmpdir
- ctx.run(f"mypy --config-file {tmpconfig} {PY_SRC}", title="Type-checking", pty=PTY)
+ os.environ["MYPYPATH"] = "src"
+ ctx.run(f"mypy --config-file config/mypy.ini {PY_SRC}", title="Type-checking", pty=PTY)
@duty(silent=True)
diff --git a/pyproject.toml b/pyproject.toml
index 409a40be..914bd58b 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -6,7 +6,7 @@ build-backend = "pdm.pep517.api"
name = "mkdocstrings-python"
description = "A Python handler for mkdocstrings."
authors = [{name = "Timothée Mazzucotelli", email = "pawamoy@pm.me"}]
-license-expression = "ISC"
+license = "ISC"
readme = "README.md"
requires-python = ">=3.7"
keywords = []
@@ -30,7 +30,7 @@ classifiers = [
]
dependencies = [
"mkdocstrings>=0.19",
- "griffe>=0.11.1",
+ "griffe>=0.24",
]
[project.urls]
@@ -44,7 +44,10 @@ Gitter = "https://gitter.im/python/community"
Funding = "https://github.com/sponsors/mkdocstrings"
[tool.pdm]
-version = {use_scm = true}
+version = {source = "scm"}
+
+[tool.pdm.build]
+package-dir = "src"
includes = ["src/mkdocstrings_handlers"]
editable-backend = "editables"
@@ -70,6 +73,10 @@ maintain = [
"git-changelog>=0.4",
]
quality = [
+ # TODO: remove once importlib-metadata version conflict is resolved
+ "importlib-metadata<5; python_version < '3.8'",
+ "flake8>=4; python_version >= '3.8'",
+
"darglint>=1.8",
"flake8-bandit>=2.1",
"flake8-black>=0.2",
@@ -95,7 +102,7 @@ typing = [
"types-markdown>=3.3",
"types-toml>=0.10",
]
-security = ["safety>=1.10"]
+security = ["safety>=2"]
[tool.black]
line-length = 120
diff --git a/scripts/gen_credits.py b/scripts/gen_credits.py
index a21a1e4a..10f5647d 100644
--- a/scripts/gen_credits.py
+++ b/scripts/gen_credits.py
@@ -58,7 +58,7 @@ def get_deps(base_deps):
if dep_name not in deps:
deps[dep_name] = {"license": get_license(dep_name), **parsed, **lock_pkgs[dep_name]}
again = True
-
+
return deps
dev_dependencies = get_deps(chain(*pdm.get("dev-dependencies", {}).values()))
diff --git a/src/mkdocstrings_handlers/python/handler.py b/src/mkdocstrings_handlers/python/handler.py
index 301f02fc..0288afa5 100644
--- a/src/mkdocstrings_handlers/python/handler.py
+++ b/src/mkdocstrings_handlers/python/handler.py
@@ -2,6 +2,7 @@
from __future__ import annotations
+import glob
import os
import posixpath
import re
@@ -106,7 +107,8 @@ class PythonHandler(BaseHandler):
annotations_path (str): The verbosity for annotations path: `brief` (recommended), or `source` (as written in the source). Default: `"brief"`.
show_signature (bool): Show methods and functions signatures. Default: `True`.
show_signature_annotations (bool): Show the type annotations in methods and functions signatures. Default: `False`.
- separate_signature (bool): Whether to put the whole signature in a code block below the heading. Default: `False`.
+ separate_signature (bool): Whether to put the whole signature in a code block below the heading.
+ If Black is installed, the signature is also formatted using it. Default: `False`.
Attributes: Additional options:
show_bases (bool): Show the base classes of a class. Default: `True`.
@@ -127,6 +129,8 @@ def __init__(
super().__init__(*args, **kwargs)
self._config_file_path = config_file_path
paths = paths or []
+ resolved_globs = [glob.glob(path) for path in paths]
+ paths = [path for glob_list in resolved_globs for path in glob_list]
if not paths and config_file_path:
paths.append(os.path.dirname(config_file_path))
search_paths = [path for path in sys.path if path] # eliminate empty path
@@ -192,7 +196,7 @@ def collect(self, identifier: str, config: dict) -> CollectorItem: # noqa: D102
except ImportError as error:
raise CollectionError(str(error)) from error
- unresolved, iterations = loader.resolve_aliases(only_exported=True, only_known_modules=True)
+ unresolved, iterations = loader.resolve_aliases(implicit=False, external=False)
if unresolved:
logger.warning(f"{len(unresolved)} aliases were still unresolved after {iterations} iterations")
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/signature.html b/src/mkdocstrings_handlers/python/templates/material/_base/signature.html
index d571c73e..bc24ea35 100644
--- a/src/mkdocstrings_handlers/python/templates/material/_base/signature.html
+++ b/src/mkdocstrings_handlers/python/templates/material/_base/signature.html
@@ -35,6 +35,7 @@
{%- set ns.render_kw_only_separator = False -%}
{%- endif -%}
+ {% if parameter.kind.value == "variadic positional" %}*{% elif parameter.kind.value == "variadic keyword" %}**{% endif -%}
{{ parameter.name }}{{ annotation }}{{ default }}
{%- if not loop.last %}, {% endif -%}
diff --git a/tests/conftest.py b/tests/conftest.py
index 6e7766b1..ce71a665 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -7,18 +7,7 @@
import pytest
from markdown.core import Markdown
from mkdocs import config
-
-try:
- from mkdocs.config.defaults import get_schema
-except ImportError:
-
- def get_schema() -> tuple[tuple]: # noqa: WPS440
- """Fallback for old versions of MkDocs.
-
- Returns:
- The default schema.
- """
- return config.DEFAULT_SCHEMA
+from mkdocs.config.defaults import get_schema
@pytest.fixture(name="mkdocs_conf")