Skip to content

Commit

Permalink
Revert "fix: Parse Deprecated sections in Google-style docstrings"
Browse files Browse the repository at this point in the history
This reverts commit 3ad6333.
  • Loading branch information
pawamoy committed Jan 18, 2025
1 parent 3ad6333 commit 38d8770
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 78 deletions.
4 changes: 2 additions & 2 deletions src/_griffe/docstrings/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
"modules": DocstringSectionKind.modules,
"warns": DocstringSectionKind.warns,
"warnings": DocstringSectionKind.warns,
"deprecated": DocstringSectionKind.deprecated,
}

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

version = version.lstrip()
description = text.lstrip()
Expand Down
76 changes: 0 additions & 76 deletions tests/test_docstrings/test_google.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,28 +525,6 @@ def test_parse_yields_section(parse_google: ParserType) -> None:
assert "'x'" in warnings[0]


def test_parse_deprecated_section(parse_google: ParserType) -> None:
"""Parse Deprecated section.
See [`mkdocstrings/griffe#352`](https://github.com/mkdocstrings/griffe/issues/352)
for context.
Parameters:
parse_google: Fixture parser.
"""
docstring = """
Deprecated:
1.0: This function is deprecated.
"""
sections, warnings = parse_google(docstring)
assert len(sections) == 1
deprecated = sections[0]
assert deprecated.kind is DocstringSectionKind.deprecated
assert deprecated.value.version == "1.0"
assert deprecated.value.description == "This function is deprecated."
assert not warnings


def test_invalid_sections(parse_google: ParserType) -> None:
"""Warn on invalid sections.
Expand Down Expand Up @@ -1153,60 +1131,6 @@ def test_parse_returns_tuple_in_generator(parse_google: ParserType) -> None:
assert returns[1].annotation.name == "float"


# =============================================================================================
# Deprecated sections


def test_parse_deprecated_section_missing_version(parse_google: ParserType) -> None:
"""Parse version numbers in Deprecated sections that aren't numbers.
See [`mkdocstrings/griffe#352`](https://github.com/mkdocstrings/griffe/issues/352)
for context.
Parameters:
parse_google: Fixture parser.
"""
docstring = """
Summary.
Deprecated:
Since "Dapper Drake": This function is deprecated.
"""
sections, warnings = parse_google(docstring)
assert len(sections) == 2
deprecated = sections[1]
assert deprecated.kind is DocstringSectionKind.deprecated
assert deprecated.value.version == 'Since "Dapper Drake"'
assert deprecated.value.description == "This function is deprecated."
assert not warnings


def test_dont_warn_about_missing_deprecated_version(parse_google: ParserType) -> None:
"""Don't warn about missing version info in Deprecated sections.
Also assert that we don't just swallow the section, but actually parse it.
See [`mkdocstrings/griffe#352`](https://github.com/mkdocstrings/griffe/issues/352)
for context.
Parameters:
parse_google: Fixture parser.
"""
docstring = """
Summary.
Deprecated:
This function is deprecated since v0.9alpha1.
"""
sections, warnings = parse_google(docstring)
assert len(sections) == 2
deprecated = sections[1]
assert deprecated.kind is DocstringSectionKind.deprecated
assert not deprecated.value.version
assert deprecated.value.description == "This function is deprecated since v0.9alpha1."
assert not warnings


# =============================================================================================
# Parser special features
def test_parse_admonitions(parse_google: ParserType) -> None:
Expand Down

0 comments on commit 38d8770

Please sign in to comment.