Skip to content

Commit 9ee7247

Browse files
committed
Update: Remove redundant data type docstrings (#386)
1 parent a6c6a1e commit 9ee7247

File tree

15 files changed

+16
-146
lines changed

15 files changed

+16
-146
lines changed

src/fake_bpy_module/generator/writers.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,6 @@ def _write_function_code(self,
344344
dtype_node, 'FUNC_ARG'):
345345
dtype_str = f"{dtype_str} | None"
346346
break
347-
wt.addln(f":type {name_node.astext()}: "
348-
f"{dtype_str}")
349347

350348
if not return_node.empty():
351349
desc_node = return_node.element(DescriptionNode)
@@ -364,7 +362,6 @@ def _write_function_code(self,
364362
dtype_node, 'FUNC_RET'):
365363
dtype = f"{dtype} | None"
366364
break
367-
wt.addln(f":rtype: {dtype}")
368365
wt.addln("'''")
369366
else:
370367
wt.addln(self.ellipsis_strings["method"])
@@ -398,7 +395,6 @@ def _write_function_code(self,
398395
if self._is_accept_none(dtype_node, 'FUNC_ARG'):
399396
dtype_str = f"{dtype_str} | None"
400397
break
401-
wt.addln(f":type {name_node.astext()}: {dtype_str}")
402398
if not return_node.empty():
403399
desc_node = return_node.element(DescriptionNode)
404400
dtype_list_node = return_node.element(DataTypeListNode)
@@ -413,7 +409,6 @@ def _write_function_code(self,
413409
if self._is_accept_none(dtype_node, 'FUNC_RET'):
414410
dtype = f"{dtype} | None"
415411
break
416-
wt.addln(f":rtype: {dtype}")
417412
wt.addln("'''")
418413
else:
419414
wt.addln(self.ellipsis_strings["function"])
@@ -495,18 +490,15 @@ def _write_class_code(self, class_node: ClassNode) -> None:
495490
wt.addln(f"{name_node.astext()}: typing.Any"
496491
f"{self.ellipsis_strings['attribute']}")
497492

498-
if (not desc_node.empty()) or (dtype_str is not None):
493+
if not desc_node.empty():
499494
wt.add("''' ")
500495
if not desc_node.empty():
501496
desc_text = desc_node.astext()
502497
wt.add(f"{desc_text}")
503498
# Add a space to avoid syntax error
504499
# with 4 single quotes in a row.
505-
if dtype_str is None and desc_text.endswith("'"):
500+
if desc_text.endswith("'"):
506501
wt.add(' ')
507-
if dtype_str is not None:
508-
wt.new_line(2)
509-
wt.addln(f":type: {dtype_str}")
510502
wt.addln("'''")
511503
wt.new_line(1)
512504
if len(attr_nodes) > 0:

tests/python/fake_bpy_module_test/fake_bpy_module_test/generator_test_data/py_code_writer_test/expect/class/class.py

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,83 +8,59 @@ class ClassA:
88
"""ClassA description"""
99

1010
attr_1: float = None
11-
""" attr_1 description
12-
13-
:type: float
14-
"""
11+
""" attr_1 description"""
1512

1613
data_1: int = None
17-
""" data_1 description
18-
19-
:type: int
20-
"""
14+
""" data_1 description"""
2115

2216
def method_1(self, arg_1: float, arg_2: str = "test") -> str:
2317
"""method_1 description
2418
2519
:param arg_1: method_1 arg_1 description
26-
:type arg_1: float
2720
:param arg_2: method_1 arg_2 description
28-
:type arg_2: str
2921
:return: method_1 return description
30-
:rtype: str
3122
"""
3223

3324
@classmethod
3425
def classmethod_1(cls, arg_1: float, arg_2: int = 123) -> str:
3526
"""classmethod_1 description
3627
3728
:param arg_1: classmethod_1 arg_1 description
38-
:type arg_1: float
3929
:param arg_2: classmethod_1 arg_2 description
40-
:type arg_2: int
4130
:return: classmethod_1 return description
42-
:rtype: str
4331
"""
4432

4533
@staticmethod
4634
def staticmethod_1(arg_1: float, arg_2: tuple = (0, 0)) -> str:
4735
"""staticmethod_1 description
4836
4937
:param arg_1: staticmethod_1 arg_1 description
50-
:type arg_1: float
5138
:param arg_2: staticmethod_1 arg_2 description
52-
:type arg_2: tuple
5339
:return: staticmethod_1 return description
54-
:rtype: str
5540
"""
5641

5742
@typing.overload
5843
def function_1(self, arg_1: float, arg_2: int) -> str | None:
5944
"""function_1 description
6045
6146
:param arg_1: function_1 arg_1 description
62-
:type arg_1: float
6347
:param arg_2: function_1 arg_2 description
64-
:type arg_2: int
6548
:return: function_1 return description
66-
:rtype: str | None
6749
"""
6850

6951

7052
class ClassB[_GenericType1]:
7153
"""ClassB description"""
7254

7355
attr_1: _GenericType1 = None
74-
""" attr_1 description
75-
76-
:type: _GenericType1
77-
"""
56+
""" attr_1 description"""
7857

7958
def method_1[_GenericType2](
8059
self, arg_1: _GenericType1, arg_2: _GenericType2
8160
) -> _GenericType2:
8261
"""method_1 description
8362
8463
:param arg_1: method_1 arg_1 description
85-
:type arg_1: _GenericType1
8664
:param arg_2: method_1 arg_2 description
87-
:type arg_2: _GenericType2
8865
:return: method_1 return description
89-
:rtype: _GenericType2
9066
"""

tests/python/fake_bpy_module_test/fake_bpy_module_test/generator_test_data/py_code_writer_test/expect/function/function.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,21 @@ def function_1(arg_1: float, arg_2: str = "test", arg_3: int = 1234) -> str:
88
"""function_1 description
99
1010
:param arg_1: function_1 arg_1 description
11-
:type arg_1: float
1211
:param arg_2: function_1 arg_2 description
13-
:type arg_2: str
1412
:param arg_3: function_1 arg_3 description
15-
:type arg_3: int
1613
:return: function_1 return description
17-
:rtype: str
1814
"""
1915

2016

2117
def function_2() -> str | None:
2218
"""
2319
2420
:return: function_2 return description
25-
:rtype: str | None
2621
"""
2722

2823

2924
def function_3[_GenericType1]() -> _GenericType1:
3025
"""
3126
3227
:return: function_3 return description
33-
:rtype: _GenericType1
3428
"""

tests/python/fake_bpy_module_test/fake_bpy_module_test/generator_test_data/py_interface_writer_test/expect/class/class.pyi

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,82 +7,58 @@ class ClassA:
77
"""ClassA description"""
88

99
attr_1: float
10-
""" attr_1 description
11-
12-
:type: float
13-
"""
10+
""" attr_1 description"""
1411

1512
data_1: int
16-
""" data_1 description
17-
18-
:type: int
19-
"""
13+
""" data_1 description"""
2014

2115
def method_1(self, arg_1: float, arg_2: str = "test") -> str:
2216
"""method_1 description
2317
2418
:param arg_1: method_1 arg_1 description
25-
:type arg_1: float
2619
:param arg_2: method_1 arg_2 description
27-
:type arg_2: str
2820
:return: method_1 return description
29-
:rtype: str
3021
"""
3122

3223
@classmethod
3324
def classmethod_1(cls, arg_1: float, arg_2: int = 123) -> str:
3425
"""classmethod_1 description
3526
3627
:param arg_1: classmethod_1 arg_1 description
37-
:type arg_1: float
3828
:param arg_2: classmethod_1 arg_2 description
39-
:type arg_2: int
4029
:return: classmethod_1 return description
41-
:rtype: str
4230
"""
4331

4432
@staticmethod
4533
def staticmethod_1(arg_1: float, arg_2: tuple = (0, 0)) -> str:
4634
"""staticmethod_1 description
4735
4836
:param arg_1: staticmethod_1 arg_1 description
49-
:type arg_1: float
5037
:param arg_2: staticmethod_1 arg_2 description
51-
:type arg_2: tuple
5238
:return: staticmethod_1 return description
53-
:rtype: str
5439
"""
5540

5641
@typing.overload
5742
def function_1(self, arg_1: float, arg_2: int) -> str | None:
5843
"""function_1 description
5944
6045
:param arg_1: function_1 arg_1 description
61-
:type arg_1: float
6246
:param arg_2: function_1 arg_2 description
63-
:type arg_2: int
6447
:return: function_1 return description
65-
:rtype: str | None
6648
"""
6749

6850
class ClassB[_GenericType1]:
6951
"""ClassB description"""
7052

7153
attr_1: _GenericType1
72-
""" attr_1 description
73-
74-
:type: _GenericType1
75-
"""
54+
""" attr_1 description"""
7655

7756
def method_1[_GenericType2](
7857
self, arg_1: _GenericType1, arg_2: _GenericType2
7958
) -> _GenericType2:
8059
"""method_1 description
8160
8261
:param arg_1: method_1 arg_1 description
83-
:type arg_1: _GenericType1
8462
:param arg_2: method_1 arg_2 description
85-
:type arg_2: _GenericType2
8663
:return: method_1 return description
87-
:rtype: _GenericType2
8864
"""

tests/python/fake_bpy_module_test/fake_bpy_module_test/generator_test_data/py_interface_writer_test/expect/function/function.pyi

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,19 @@ def function_1(arg_1: float, arg_2: str = "test", arg_3: int = 1234) -> str:
77
"""function_1 description
88
99
:param arg_1: function_1 arg_1 description
10-
:type arg_1: float
1110
:param arg_2: function_1 arg_2 description
12-
:type arg_2: str
1311
:param arg_3: function_1 arg_3 description
14-
:type arg_3: int
1512
:return: function_1 return description
16-
:rtype: str
1713
"""
1814

1915
def function_2() -> str | None:
2016
"""
2117
2218
:return: function_2 return description
23-
:rtype: str | None
2419
"""
2520

2621
def function_3[_GenericType1]() -> _GenericType1:
2722
"""
2823
2924
:return: function_3 return description
30-
:rtype: _GenericType1
3125
"""

tests/python/fake_bpy_module_test/fake_bpy_module_test/integration_test_data/integration_test/expect/exceptional/module_exceptional/__init__.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,24 @@ class ClassExp:
88
"""ClassExp description"""
99

1010
attr: float = None
11-
""" attr description
12-
13-
:type: float
14-
"""
11+
""" attr description"""
1512

1613
def method_with_keyword_only_argument(
1714
self, arg_1: float, arg_2: float = 5.0, arg_3: int | None = None
1815
) -> int:
1916
"""method_with_keyword_only_argument description
2017
2118
:param arg_1: method_with_keyword_only_argument arg_1 description
22-
:type arg_1: float
2319
:param arg_2: method_with_keyword_only_argument arg_2 description
24-
:type arg_2: float
2520
:param arg_3: method_with_keyword_only_argument arg_3 description
26-
:type arg_3: int | None
2721
:return: method_with_keyword_only_argument return description
28-
:rtype: int
2922
"""
3023

3124

3225
def function_with_type_hint(arg_1: float, arg_2: bool) -> int:
3326
"""function_with_type_hint description
3427
3528
:param arg_1: function_with_type_hint arg_1 description
36-
:type arg_1: float
3729
:param arg_2: function_with_type_hint arg_2 description
38-
:type arg_2: bool
3930
:return: function_with_type_hint return description
40-
:rtype: int
4131
"""

tests/python/fake_bpy_module_test/fake_bpy_module_test/integration_test_data/integration_test/expect/exceptional/module_exceptional/__init__.pyi

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,23 @@ class ClassExp:
77
"""ClassExp description"""
88

99
attr: float
10-
""" attr description
11-
12-
:type: float
13-
"""
10+
""" attr description"""
1411

1512
def method_with_keyword_only_argument(
1613
self, arg_1: float, arg_2: float = 5.0, arg_3: int | None = None
1714
) -> int:
1815
"""method_with_keyword_only_argument description
1916
2017
:param arg_1: method_with_keyword_only_argument arg_1 description
21-
:type arg_1: float
2218
:param arg_2: method_with_keyword_only_argument arg_2 description
23-
:type arg_2: float
2419
:param arg_3: method_with_keyword_only_argument arg_3 description
25-
:type arg_3: int | None
2620
:return: method_with_keyword_only_argument return description
27-
:rtype: int
2821
"""
2922

3023
def function_with_type_hint(arg_1: float, arg_2: bool) -> int:
3124
"""function_with_type_hint description
3225
3326
:param arg_1: function_with_type_hint arg_1 description
34-
:type arg_1: float
3527
:param arg_2: function_with_type_hint arg_2 description
36-
:type arg_2: bool
3728
:return: function_with_type_hint return description
38-
:rtype: int
3929
"""

tests/python/fake_bpy_module_test/fake_bpy_module_test/integration_test_data/integration_test/expect/multiple/module_1/__init__.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,11 @@ class ClassA(module_1.submodule_1.BaseClass1):
1111
"""ClassA description"""
1212

1313
attr_1: str = None
14-
""" attr_1 description
15-
16-
:type: str
17-
"""
14+
""" attr_1 description"""
1815

1916
def method_1(self, arg_1: float = 5.4) -> int:
2017
"""method_1 description
2118
2219
:param arg_1: method_1 arg_1 description
23-
:type arg_1: float
2420
:return: method_1 return description
25-
:rtype: int
2621
"""

tests/python/fake_bpy_module_test/fake_bpy_module_test/integration_test_data/integration_test/expect/multiple/module_1/__init__.pyi

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,11 @@ class ClassA(module_1.submodule_1.BaseClass1):
1010
"""ClassA description"""
1111

1212
attr_1: str
13-
""" attr_1 description
14-
15-
:type: str
16-
"""
13+
""" attr_1 description"""
1714

1815
def method_1(self, arg_1: float = 5.4) -> int:
1916
"""method_1 description
2017
2118
:param arg_1: method_1 arg_1 description
22-
:type arg_1: float
2319
:return: method_1 return description
24-
:rtype: int
2520
"""

0 commit comments

Comments
 (0)