From daf0a21306383df089e0830fd9516af4edffce64 Mon Sep 17 00:00:00 2001 From: Mauricio Villegas <5780272+mauvilsa@users.noreply.github.com> Date: Fri, 15 Sep 2023 03:38:19 +0200 Subject: [PATCH] - Fix attrdoc.py to avoid ast.* deprecation warnings. - Testing and classifiers for python 3.10, 3.11 and 3.12. - Update non-working version of isort in pre-commit config. --- .github/workflows/build.yml | 2 +- .pre-commit-config.yaml | 2 +- docstring_parser/attrdoc.py | 18 +++++++++++------- pyproject.toml | 3 +++ 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 49482f9..bdd6f66 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-20.04, macOS-10.15, windows-2019] - python-version: [3.6, 3.7, 3.8, 3.9, "3.10"] + python-version: [3.6, 3.7, 3.8, 3.9, "3.10", 3.11, 3.12.0-rc.2] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6bc37c4..a2243d5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ repos: - repo: https://github.com/pycqa/isort - rev: 5.10.1 + rev: 5.12.0 hooks: - id: isort additional_dependencies: [toml] diff --git a/docstring_parser/attrdoc.py b/docstring_parser/attrdoc.py index c5a146f..ac04cb1 100644 --- a/docstring_parser/attrdoc.py +++ b/docstring_parser/attrdoc.py @@ -5,19 +5,23 @@ import ast import inspect +import sys import textwrap import typing as T from types import ModuleType from .common import Docstring, DocstringParam -ast_constant_attr = { - ast.Constant: "value", - # python <= 3.7: - ast.NameConstant: "value", - ast.Num: "n", - ast.Str: "s", -} +ast_constant_attr = {ast.Constant: "value"} + +if sys.version_info[:2] <= (3, 7): + ast_constant_attr.update( + { + ast.NameConstant: "value", + ast.Num: "n", + ast.Str: "s", + } + ) def ast_get_constant_value(node: ast.AST) -> T.Any: diff --git a/pyproject.toml b/pyproject.toml index 6dbc2a9..a6eca0c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,6 +21,9 @@ classifiers = [ "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", + "Programming Language :: Python :: 3.12", "Topic :: Documentation :: Sphinx", "Topic :: Text Processing :: Markup", "Topic :: Software Development :: Libraries :: Python Modules",