Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
9 changes: 9 additions & 0 deletions flake8_docstrings_complete/raises.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <david@jdkandersson.com>"]
license = "Apache 2.0"
Expand Down
25 changes: 25 additions & 0 deletions tests/unit/test___init__raises.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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():
Expand Down