Skip to content

Commit 38d8770

Browse files
committed
Revert "fix: Parse Deprecated sections in Google-style docstrings"
This reverts commit 3ad6333.
1 parent 3ad6333 commit 38d8770

2 files changed

Lines changed: 2 additions & 78 deletions

File tree

src/_griffe/docstrings/google.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
"modules": DocstringSectionKind.modules,
7070
"warns": DocstringSectionKind.warns,
7171
"warnings": DocstringSectionKind.warns,
72-
"deprecated": DocstringSectionKind.deprecated,
7372
}
7473

7574
_BlockItem = tuple[int, list[str]]
@@ -706,7 +705,8 @@ def _read_deprecated_section(
706705
try:
707706
version, text = text.split(":", 1)
708707
except ValueError:
709-
version = ""
708+
docstring_warning(docstring, new_offset, f"Could not parse version, text at line {offset}")
709+
return None, new_offset
710710

711711
version = version.lstrip()
712712
description = text.lstrip()

tests/test_docstrings/test_google.py

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -525,28 +525,6 @@ def test_parse_yields_section(parse_google: ParserType) -> None:
525525
assert "'x'" in warnings[0]
526526

527527

528-
def test_parse_deprecated_section(parse_google: ParserType) -> None:
529-
"""Parse Deprecated section.
530-
531-
See [`mkdocstrings/griffe#352`](https://github.com/mkdocstrings/griffe/issues/352)
532-
for context.
533-
534-
Parameters:
535-
parse_google: Fixture parser.
536-
"""
537-
docstring = """
538-
Deprecated:
539-
1.0: This function is deprecated.
540-
"""
541-
sections, warnings = parse_google(docstring)
542-
assert len(sections) == 1
543-
deprecated = sections[0]
544-
assert deprecated.kind is DocstringSectionKind.deprecated
545-
assert deprecated.value.version == "1.0"
546-
assert deprecated.value.description == "This function is deprecated."
547-
assert not warnings
548-
549-
550528
def test_invalid_sections(parse_google: ParserType) -> None:
551529
"""Warn on invalid sections.
552530
@@ -1153,60 +1131,6 @@ def test_parse_returns_tuple_in_generator(parse_google: ParserType) -> None:
11531131
assert returns[1].annotation.name == "float"
11541132

11551133

1156-
# =============================================================================================
1157-
# Deprecated sections
1158-
1159-
1160-
def test_parse_deprecated_section_missing_version(parse_google: ParserType) -> None:
1161-
"""Parse version numbers in Deprecated sections that aren't numbers.
1162-
1163-
See [`mkdocstrings/griffe#352`](https://github.com/mkdocstrings/griffe/issues/352)
1164-
for context.
1165-
1166-
Parameters:
1167-
parse_google: Fixture parser.
1168-
"""
1169-
docstring = """
1170-
Summary.
1171-
1172-
Deprecated:
1173-
Since "Dapper Drake": This function is deprecated.
1174-
"""
1175-
sections, warnings = parse_google(docstring)
1176-
assert len(sections) == 2
1177-
deprecated = sections[1]
1178-
assert deprecated.kind is DocstringSectionKind.deprecated
1179-
assert deprecated.value.version == 'Since "Dapper Drake"'
1180-
assert deprecated.value.description == "This function is deprecated."
1181-
assert not warnings
1182-
1183-
1184-
def test_dont_warn_about_missing_deprecated_version(parse_google: ParserType) -> None:
1185-
"""Don't warn about missing version info in Deprecated sections.
1186-
1187-
Also assert that we don't just swallow the section, but actually parse it.
1188-
1189-
See [`mkdocstrings/griffe#352`](https://github.com/mkdocstrings/griffe/issues/352)
1190-
for context.
1191-
1192-
Parameters:
1193-
parse_google: Fixture parser.
1194-
"""
1195-
docstring = """
1196-
Summary.
1197-
1198-
Deprecated:
1199-
This function is deprecated since v0.9alpha1.
1200-
"""
1201-
sections, warnings = parse_google(docstring)
1202-
assert len(sections) == 2
1203-
deprecated = sections[1]
1204-
assert deprecated.kind is DocstringSectionKind.deprecated
1205-
assert not deprecated.value.version
1206-
assert deprecated.value.description == "This function is deprecated since v0.9alpha1."
1207-
assert not warnings
1208-
1209-
12101134
# =============================================================================================
12111135
# Parser special features
12121136
def test_parse_admonitions(parse_google: ParserType) -> None:

0 commit comments

Comments
 (0)