From 3dd3eca2b9a4cdd5dab163e6a19e9ecdbb0abbcd Mon Sep 17 00:00:00 2001 From: Dominic Davis-Foster Date: Mon, 14 Sep 2020 12:00:29 +0100 Subject: [PATCH] Linting --- __pkginfo__.py | 2 +- attr_utils/docstrings.py | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/__pkginfo__.py b/__pkginfo__.py index d4fe5e1..ea8ab3d 100644 --- a/__pkginfo__.py +++ b/__pkginfo__.py @@ -51,7 +51,7 @@ web = github_url = "https://github.com/domdfcoding/attr_utils" repo_root = pathlib.Path(__file__).parent install_requires = (repo_root / "requirements.txt").read_text(encoding="utf-8").split('\n') -extras_require = {'sphinx': ['sphinx>=3.0.3', 'sphinx_toolbox>=0.4.0'], 'all': ['sphinx>=3.0.3', 'sphinx_toolbox>=0.4.0']} +extras_require = {'sphinx': ['sphinx>=3.0.3', 'sphinx_toolbox>=0.6.0'], 'all': ['sphinx>=3.0.3', 'sphinx_toolbox>=0.6.0']} diff --git a/attr_utils/docstrings.py b/attr_utils/docstrings.py index be12b2a..3a89ea3 100644 --- a/attr_utils/docstrings.py +++ b/attr_utils/docstrings.py @@ -29,9 +29,10 @@ # stdlib import re from typing import Optional, Pattern, Type -from domdf_python_tools.doctools import base_new_docstrings, prettify_docstrings, PYPY -from domdf_python_tools.typing import MethodDescriptorType, MethodWrapperType, WrapperDescriptorType +# 3rd party +from domdf_python_tools.doctools import PYPY, base_new_docstrings, prettify_docstrings +from domdf_python_tools.typing import MethodDescriptorType, MethodWrapperType, WrapperDescriptorType __all__ = ["add_attrs_doc"] @@ -59,9 +60,9 @@ def add_attrs_doc(obj: Type) -> Type: if hasattr(obj, "__repr__"): if ( - obj.__repr__.__doc__.strip() == attrs_docstring + obj.__repr__.__doc__ is None or obj.__repr__.__doc__.strip() == attrs_docstring or attrs_20_1_docstring.match(obj.__repr__.__doc__) - ): + ): _new_doc = f"{new_docstrings['__repr__']}" # \n\n{attrs_docstring} obj.__repr__.__doc__ = _new_doc # prevents strange formatting in pycharm @@ -80,11 +81,7 @@ def add_attrs_doc(obj: Type) -> Type: doc: Optional[str] = attribute.__doc__ - if ( - doc is None - or doc.strip() == attrs_docstring - or attrs_20_1_docstring.match(doc) - ): + if doc is None or doc.strip() == attrs_docstring or attrs_20_1_docstring.match(doc): _new_doc = f"{new_docstrings[attr_name]}" # \n\n{attrs_docstring} attribute.__doc__ = _new_doc # prevents strange formatting in pycharm