-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix attribute parser for Python 3.9
It seems `ast` has changed in Python 3.9. Some objects who previously had a `value` attribute don't have it anymore. Issue #73: #73 Issue #75: #75
- Loading branch information
Showing
3 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from typing import Any, Dict, List | ||
|
||
|
||
class C: | ||
def __init__(self): | ||
# https://github.com/pawamoy/pytkdocs/issues/73 | ||
self.dict_annotation: Dict[str, Any] = {} | ||
|
||
# https://github.com/pawamoy/pytkdocs/issues/75 | ||
self.list_annotation: List[str] = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
"""Tests for [the `parsers.attributes` module][pytkdocs.parsers.attributes] on annotations.""" | ||
|
||
|
||
from tests.fixtures.parsing import annotations | ||
|
||
from pytkdocs.parsers.attributes import get_instance_attributes | ||
|
||
|
||
class TestAnnotations: | ||
def setup(self): | ||
"""Setup reusable attributes.""" | ||
self.attributes = get_instance_attributes(annotations.C.__init__) | ||
|
||
def test_parse_dict_annotation(self): | ||
assert "dict_annotation" in self.attributes | ||
assert self.attributes["dict_annotation"]["annotation"] == "Dict[str, Any]" | ||
|
||
def test_parse_list_annotation(self): | ||
assert "list_annotation" in self.attributes | ||
assert self.attributes["list_annotation"]["annotation"] == "List[str]" |