Skip to content

Commit 9ad53b8

Browse files
committed
Update code to modern python
1 parent 7f8bf06 commit 9ad53b8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+1464
-819
lines changed

.pylintrc

Lines changed: 586 additions & 0 deletions
Large diffs are not rendered by default.

docs/MODULES.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Full list of [Handsdown](README.md#-handsdown---python-documentation-generator)
1919
- [PEP 484 - type annotations examples](examples/typed.md#pep-484---type-annotations-examples)
2020
- [Handsdown](handsdown/index.md#handsdown)
2121
- [Module](handsdown/module.md#module)
22-
- [AST Parser](handsdown/ast_parser/index.md#ast-parser)
22+
- [AST Parser.](handsdown/ast_parser/index.md#ast-parser)
2323
- [Analyzers](handsdown/ast_parser/analyzers/index.md#analyzers)
2424
- [BaseAnalyzer](handsdown/ast_parser/analyzers/base_analyzer.md#baseanalyzer)
2525
- [ClassAnalyzer](handsdown/ast_parser/analyzers/class_analyzer.md#classanalyzer)
@@ -38,24 +38,23 @@ Full list of [Handsdown](README.md#-handsdown---python-documentation-generator)
3838
- [ModuleRecord](handsdown/ast_parser/node_records/module_record.md#modulerecord)
3939
- [NodeRecord](handsdown/ast_parser/node_records/node_record.md#noderecord)
4040
- [TextRecord](handsdown/ast_parser/node_records/text_record.md#textrecord)
41-
- [Smart AST](handsdown/ast_parser/smart_ast.md#smart-ast)
41+
- [Smart Ast](handsdown/ast_parser/smart_ast.md#smart-ast)
4242
- [Type Defs](handsdown/ast_parser/type_defs.md#type-defs)
43-
- [CLI Parser](handsdown/cli_parser.md#cli-parser)
43+
- [Cli Parser](handsdown/cli_parser.md#cli-parser)
4444
- [Generator](handsdown/generator.md#generator)
4545
- [Loader](handsdown/loader.md#loader)
4646
- [Main](handsdown/main.md#main)
4747
- [MDDocument](handsdown/md_document.md#mddocument)
4848
- [Processors](handsdown/processors/index.md#processors)
49-
- [Base Docstring Processor](handsdown/processors/base.md#base-docstring-processor)
50-
- [PEP 257 Docstring Processor](handsdown/processors/pep257.md#pep-257-docstring-processor)
51-
- [reStructuredText Docstring Processor](handsdown/processors/rst.md#restructuredtext-docstring-processor)
49+
- [Base Docstring Processor.](handsdown/processors/base.md#base-docstring-processor)
50+
- [PEP 257 Docstring Processor.](handsdown/processors/pep257.md#pep-257-docstring-processor)
51+
- [reStructuredText Docstring Processor.](handsdown/processors/rst.md#restructuredtext-docstring-processor)
5252
- [SectionMap](handsdown/processors/section_map.md#sectionmap)
53-
- [Smart Docstring Processor](handsdown/processors/smart.md#smart-docstring-processor)
53+
- [Smart](handsdown/processors/smart.md#smart)
5454
- [Settings](handsdown/settings.md#settings)
5555
- [Utils](handsdown/utils/index.md#utils)
5656
- [DocstringFormatter](handsdown/utils/docstring_formatter.md#docstringformatter)
5757
- [ImportString](handsdown/utils/import_string.md#importstring)
5858
- [IndentTrimmer](handsdown/utils/indent_trimmer.md#indenttrimmer)
5959
- [Logger](handsdown/utils/logger.md#logger)
6060
- [PathFinder](handsdown/utils/path_finder.md#pathfinder)
61-
- [Version](handsdown/version.md#version)

docs/examples/comment_typed.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,22 @@
2020

2121
```python
2222
class MyValue():
23+
def __init__(*args, **kwargs) -> None:
2324
```
2425

2526
## Typed
2627

27-
[[find in source code]](https://github.com/vemel/handsdown/blob/master/examples/comment_typed.py#L16)
28+
[[find in source code]](https://github.com/vemel/handsdown/blob/master/examples/comment_typed.py#L18)
2829

2930
```python
3031
class Typed():
3132
def __init__(
3233
my_bool: bool = one & ~two == 'three' and not -4,
3334
my_lambda=lambda x, y, *args, **kwargs: x + y,
3435
my_set: Set = {1, 2, [3, 4], {5: 6}, (7, 8)},
35-
_value: Union[List[Text], Text, MyValue] = MyValue('asd', *args, kwarg=123, **extras),
36-
_name: Text = 'default',
37-
) -> Dict[Text, MyValue]:
36+
_value: Union[List[str], str, MyValue] = MyValue('asd', *args, kwarg=123, **extras),
37+
_name: str = 'default',
38+
) -> None:
3839
```
3940

4041
#### Attributes
@@ -51,7 +52,7 @@ class Typed():
5152

5253
```python
5354
@classmethod
54-
def classmethod(_my_value: MyValue, *_args: Text, **_kwargs: Any) -> Typed:
55+
def classmethod(_my_value: MyValue, *_args: str, **_kwargs: Any) -> Typed:
5556
```
5657

5758
#### See also
@@ -64,7 +65,7 @@ def classmethod(_my_value: MyValue, *_args: Text, **_kwargs: Any) -> Typed:
6465

6566
```python
6667
def func(
67-
_list: Tuple[List[Text], ...],
68+
_list: Tuple[List[str], ...],
6869
_my_value_cls: Type[MyValue] = MyValue,
6970
**_kwargs: None,
7071
) -> Any:
@@ -80,7 +81,7 @@ def func(
8081

8182
```python
8283
def func_any(
83-
_list: Tuple[List[Text], ...],
84+
_list: Tuple[List[str], ...],
8485
_my_value_cls: Any = MyValue,
8586
**_kwargs: None,
8687
) -> Any:

docs/examples/google_docstrings.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111

1212
## Links
1313

14-
[Google Python Style Guide](http://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings)
14+
[Google Python Style Guide](
15+
http://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings
16+
)
1517

1618
## ClassExample
1719

18-
[[find in source code]](https://github.com/vemel/handsdown/blob/master/examples/google_docstrings.py#L12)
20+
[[find in source code]](https://github.com/vemel/handsdown/blob/master/examples/google_docstrings.py#L13)
1921

2022
```python
2123
class ClassExample():
@@ -30,10 +32,10 @@ Google-style class example
3032

3133
### ClassExample().method_example
3234

33-
[[find in source code]](https://github.com/vemel/handsdown/blob/master/examples/google_docstrings.py#L21)
35+
[[find in source code]](https://github.com/vemel/handsdown/blob/master/examples/google_docstrings.py#L22)
3436

3537
```python
36-
def method_example(text: Text = 'hello') -> int:
38+
def method_example(text: str = 'hello') -> int:
3739
```
3840

3941
Summary line.
@@ -74,7 +76,7 @@ to use the function
7476

7577
## function_example
7678

77-
[[find in source code]](https://github.com/vemel/handsdown/blob/master/examples/google_docstrings.py#L55)
79+
[[find in source code]](https://github.com/vemel/handsdown/blob/master/examples/google_docstrings.py#L56)
7880

7981
```python
8082
def function_example(arg1, arg2, arg3=None):
@@ -114,7 +116,7 @@ print result
114116

115117
## function_with_pep484_type_annotations
116118

117-
[[find in source code]](https://github.com/vemel/handsdown/blob/master/examples/google_docstrings.py#L86)
119+
[[find in source code]](https://github.com/vemel/handsdown/blob/master/examples/google_docstrings.py#L87)
118120

119121
```python
120122
def function_with_pep484_type_annotations(param1: int, param2: str) -> bool:

docs/examples/main_example.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Changed in version 1.4
9999
[[find in source code]](https://github.com/vemel/handsdown/blob/master/examples/main_example.py#L27)
100100

101101
```python
102-
def hello(name: Text) -> Text:
102+
def hello(name: str) -> str:
103103
```
104104

105105
This is module function and it is added to documentation even if it does

docs/examples/pep257_docstrings.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
## ClassExample
1616

17-
[[find in source code]](https://github.com/vemel/handsdown/blob/master/examples/pep257_docstrings.py#L12)
17+
[[find in source code]](https://github.com/vemel/handsdown/blob/master/examples/pep257_docstrings.py#L11)
1818

1919
```python
2020
class ClassExample():
@@ -43,10 +43,10 @@ This is not a codeblock, test inside tildes rendered as it is
4343

4444
### ClassExample().method_example
4545

46-
[[find in source code]](https://github.com/vemel/handsdown/blob/master/examples/pep257_docstrings.py#L35)
46+
[[find in source code]](https://github.com/vemel/handsdown/blob/master/examples/pep257_docstrings.py#L34)
4747

4848
```python
49-
def method_example(text: Text = 'hello') -> int:
49+
def method_example(text: str = 'hello') -> int:
5050
```
5151

5252
Summary line.
@@ -87,7 +87,7 @@ Description of return value
8787

8888
## function_example
8989

90-
[[find in source code]](https://github.com/vemel/handsdown/blob/master/examples/pep257_docstrings.py#L68)
90+
[[find in source code]](https://github.com/vemel/handsdown/blob/master/examples/pep257_docstrings.py#L67)
9191

9292
```python
9393
def function_example(real=0.0, imag=0.0):

docs/examples/typed.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class MyValue():
3030
```python
3131
class Typed():
3232
def __init__(
33-
_value: Union[List[Text], Text, MyValue] = MyValue(
33+
_value: Union[(List[str], str, MyValue)] = MyValue(
3434
{
3535
'key1': 'value1',
3636
'key2': 'value2',
@@ -40,16 +40,16 @@ class Typed():
4040
'key6': 'value6',
4141
},
4242
),
43-
_name: Text = 'default',
44-
) -> Dict[Text, MyValue]:
43+
_name: str = 'default',
44+
) -> Dict[(str, MyValue)]:
4545
```
4646

4747
### Typed().async_method
4848

4949
[[find in source code]](https://github.com/vemel/handsdown/blob/master/examples/typed.py#L38)
5050

5151
```python
52-
async def async_method(_value: Text) -> Text:
52+
async def async_method(_value: str) -> str:
5353
```
5454

5555
### Typed.classmethod
@@ -58,7 +58,7 @@ async def async_method(_value: Text) -> Text:
5858

5959
```python
6060
@classmethod
61-
def classmethod(_my_value: MyValue, *_args: Text, **_kwargs: Any) -> None:
61+
def classmethod(_my_value: MyValue, *_args: str, **_kwargs: Any) -> None:
6262
```
6363

6464
#### See also
@@ -72,7 +72,7 @@ def classmethod(_my_value: MyValue, *_args: Text, **_kwargs: Any) -> None:
7272
```python
7373
@my_deco(key='value')
7474
def func(
75-
_list: Tuple[List[Text], ...],
75+
_list: Tuple[(List[str], ...)],
7676
_my_value_cls: Type[MyValue] = MyValue,
7777
**_kwargs: None,
7878
) -> Any:

docs/handsdown/ast_parser/analyzers/base_analyzer.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
55
Base AST analyzer.
66

7-
- [Handsdown](../../../README.md#-handsdown---python-documentation-generator) / [Modules](../../../MODULES.md#modules) / [Handsdown](../../index.md#handsdown) / [AST Parser](../index.md#ast-parser) / [Analyzers](index.md#analyzers) / BaseAnalyzer
7+
- [Handsdown](../../../README.md#-handsdown---python-documentation-generator) / [Modules](../../../MODULES.md#modules) / [Handsdown](../../index.md#handsdown) / [AST Parser.](../index.md#ast-parser) / [Analyzers](index.md#analyzers) / BaseAnalyzer
88
- [BaseAnalyzer](#baseanalyzer)
99

1010
## BaseAnalyzer
1111

12-
[[find in source code]](https://github.com/vemel/handsdown/blob/master/handsdown/ast_parser/analyzers/base_analyzer.py#L17)
12+
[[find in source code]](https://github.com/vemel/handsdown/blob/master/handsdown/ast_parser/analyzers/base_analyzer.py#L9)
1313

1414
```python
1515
class BaseAnalyzer(ast.NodeVisitor):

docs/handsdown/ast_parser/analyzers/class_analyzer.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
AST analyzer for `ast.ClassDef` records.
66

7-
- [Handsdown](../../../README.md#-handsdown---python-documentation-generator) / [Modules](../../../MODULES.md#modules) / [Handsdown](../../index.md#handsdown) / [AST Parser](../index.md#ast-parser) / [Analyzers](index.md#analyzers) / ClassAnalyzer
7+
- [Handsdown](../../../README.md#-handsdown---python-documentation-generator) / [Modules](../../../MODULES.md#modules) / [Handsdown](../../index.md#handsdown) / [AST Parser.](../index.md#ast-parser) / [Analyzers](index.md#analyzers) / ClassAnalyzer
88
- [ClassAnalyzer](#classanalyzer)
99
- [ClassAnalyzer().generic_visit](#classanalyzergeneric_visit)
1010
- [ClassAnalyzer().visit_Assign](#classanalyzervisit_assign)
@@ -14,7 +14,7 @@ AST analyzer for `ast.ClassDef` records.
1414

1515
## ClassAnalyzer
1616

17-
[[find in source code]](https://github.com/vemel/handsdown/blob/master/handsdown/ast_parser/analyzers/class_analyzer.py#L13)
17+
[[find in source code]](https://github.com/vemel/handsdown/blob/master/handsdown/ast_parser/analyzers/class_analyzer.py#L11)
1818

1919
```python
2020
class ClassAnalyzer(BaseAnalyzer):
@@ -29,10 +29,10 @@ AST analyzer for `ast.ClassDef` records.
2929

3030
### ClassAnalyzer().generic_visit
3131

32-
[[find in source code]](https://github.com/vemel/handsdown/blob/master/handsdown/ast_parser/analyzers/class_analyzer.py#L143)
32+
[[find in source code]](https://github.com/vemel/handsdown/blob/master/handsdown/ast_parser/analyzers/class_analyzer.py#L138)
3333

3434
```python
35-
def generic_visit(_node: ast.AST) -> None:
35+
def generic_visit(node: ast.AST) -> None:
3636
```
3737

3838
Do nothing for unknown `ast.AST` nodes.
@@ -43,7 +43,7 @@ Do nothing for unknown `ast.AST` nodes.
4343

4444
### ClassAnalyzer().visit_Assign
4545

46-
[[find in source code]](https://github.com/vemel/handsdown/blob/master/handsdown/ast_parser/analyzers/class_analyzer.py#L103)
46+
[[find in source code]](https://github.com/vemel/handsdown/blob/master/handsdown/ast_parser/analyzers/class_analyzer.py#L98)
4747

4848
```python
4949
def visit_Assign(node: ast.Assign) -> None:
@@ -75,7 +75,7 @@ class MyClass:
7575

7676
### ClassAnalyzer().visit_AsyncFunctionDef
7777

78-
[[find in source code]](https://github.com/vemel/handsdown/blob/master/handsdown/ast_parser/analyzers/class_analyzer.py#L85)
78+
[[find in source code]](https://github.com/vemel/handsdown/blob/master/handsdown/ast_parser/analyzers/class_analyzer.py#L80)
7979

8080
```python
8181
def visit_AsyncFunctionDef(node: ast.AsyncFunctionDef) -> None:
@@ -87,17 +87,19 @@ Adds new `FunctionRecord` entry to `method_records`.
8787

8888
#### Examples
8989

90+
```python
9091
class MyClass:
9192
async def my_method(self, arg):
9293
return await arg
94+
```
9395

9496
#### Arguments
9597

9698
- `node` - AST node.
9799

98100
### ClassAnalyzer().visit_ClassDef
99101

100-
[[find in source code]](https://github.com/vemel/handsdown/blob/master/handsdown/ast_parser/analyzers/class_analyzer.py#L26)
102+
[[find in source code]](https://github.com/vemel/handsdown/blob/master/handsdown/ast_parser/analyzers/class_analyzer.py#L23)
101103

102104
```python
103105
def visit_ClassDef(node: ast.ClassDef) -> None:
@@ -124,7 +126,7 @@ def my_func():
124126

125127
### ClassAnalyzer().visit_FunctionDef
126128

127-
[[find in source code]](https://github.com/vemel/handsdown/blob/master/handsdown/ast_parser/analyzers/class_analyzer.py#L67)
129+
[[find in source code]](https://github.com/vemel/handsdown/blob/master/handsdown/ast_parser/analyzers/class_analyzer.py#L62)
128130

129131
```python
130132
def visit_FunctionDef(node: ast.FunctionDef) -> None:
@@ -136,9 +138,11 @@ Adds new `FunctionRecord` entry to `method_records`.
136138

137139
#### Examples
138140

141+
```python
139142
class MyClass:
140143
def my_method(self, arg):
141144
return arg
145+
```
142146

143147
#### Arguments
144148

0 commit comments

Comments
 (0)