diff --git a/.flake8 b/.flake8 index 5e00723..8f045c4 100644 --- a/.flake8 +++ b/.flake8 @@ -1,7 +1,7 @@ [flake8] max-line-length = 99 max-doc-length = 99 -extend-ignore = E203,W503 +extend-ignore = E203,W503,E231,E201 per-file-ignores = tests/*:D205,D400 flake8_docstrings_complete/*:N802 diff --git a/CHANGELOG.md b/CHANGELOG.md index eadd307..4ce5d2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## [Unreleased] +## [v1.4.0] - 2024-04-11 + +### Added + +- Support for `Exception.from_exception_data`. + ## [v1.3.0] - 2023-11-29 ### Added @@ -117,3 +123,4 @@ [v1.1.0]: https://github.com/jdkandersson/flake8-docstrings-complete/releases/v1.1.0 [v1.2.0]: https://github.com/jdkandersson/flake8-docstrings-complete/releases/v1.2.0 [v1.3.0]: https://github.com/jdkandersson/flake8-docstrings-complete/releases/v1.3.0 +[v1.4.0]: https://github.com/jdkandersson/flake8-docstrings-complete/releases/v1.4.0 diff --git a/flake8_docstrings_complete/raises.py b/flake8_docstrings_complete/raises.py index 56efbbe..9f6e17c 100644 --- a/flake8_docstrings_complete/raises.py +++ b/flake8_docstrings_complete/raises.py @@ -75,6 +75,15 @@ def _get_exc_node(node: ast.Raise) -> types_.Node | None: col_offset=node.exc.func.col_offset, ) if isinstance(node.exc.func, ast.Attribute): + if ( + isinstance(node.exc.func.value, ast.Name) + and node.exc.func.attr == "from_exception_data" + ): + return types_.Node( + name=node.exc.func.value.id, + lineno=node.exc.func.lineno, + col_offset=node.exc.func.col_offset, + ) return types_.Node( name=node.exc.func.attr, lineno=node.exc.func.lineno, diff --git a/pyproject.toml b/pyproject.toml index e4026e1..5ce5b6b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "flake8-docstrings-complete" -version = "1.3.0" +version = "1.4.0" description = "A linter that checks docstrings are complete" authors = ["David Andersson "] license = "Apache 2.0" diff --git a/tests/unit/test___init__raises.py b/tests/unit/test___init__raises.py index 5fd0cce..29ebdf4 100644 --- a/tests/unit/test___init__raises.py +++ b/tests/unit/test___init__raises.py @@ -105,6 +105,18 @@ def function_1(): def function_1(): """Docstring 1. + Raises: + """ + raise Exc1.from_exception_data() +''', + (f"7:10 {EXC_NOT_IN_DOCSTR_MSG % 'Exc1'}",), + id="function raises single exc from exc data docstring no exc", + ), + pytest.param( + ''' +def function_1(): + """Docstring 1. + Raises: """ raise Exc1 @@ -493,6 +505,19 @@ def function_1(): ), pytest.param( ''' +def function_1(): + """Docstring 1. + + Raises: + Exc1: + """ + raise Exc1.from_exception_data() +''', + (), + id="function single raise exc docstring raises from exception data", + ), + pytest.param( + ''' def function_1(): """Docstring 1.""" def function_2():