Skip to content

Commit 5cc1ae2

Browse files
committed
Rename "extra_info" to "optional_info"
Feels a bit clearer to me.
1 parent 8cfe711 commit 5cc1ae2

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

docs/typing_syntax.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ Docstrings should follow a form that is inspired by the NumPyDoc style:
1616
```
1717
Section name
1818
------------
19-
name : doctype, extra_info
19+
name : doctype, optional_info
2020
Description.
2121
```
2222

2323
- `name` might be the name of a parameter, attribute or similar.
2424
- `doctype` the actual type information that will be transformed into a Python type.
25-
- `extra_info` is optional and captures anything after the first comma (that is not inside a type expression).
25+
- `optional_info` is optional and captures anything after the first comma (that is not inside a type expression).
2626
It is useful to provide additional information for readers.
2727
Its presence and content doesn't currently affect the resulting type annotation.
2828

src/docstub/_docstrings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ def optional(self, tree):
474474
logger.debug("dropping optional / default info")
475475
return lark.Discard
476476

477-
def extra_info(self, tree):
477+
def optional_info(self, tree):
478478
"""
479479
Parameters
480480
----------
@@ -484,7 +484,7 @@ def extra_info(self, tree):
484484
-------
485485
out : lark.visitors._DiscardType
486486
"""
487-
logger.debug("dropping extra info")
487+
logger.debug("dropping optional info")
488488
return lark.Discard
489489

490490
def __default__(self, data, children, meta):

src/docstub/doctype.lark

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// The basic structure of a full docstring annotation as it comes after the
1313
// `name : `. It includes additional meta information that is optional and
1414
// currently ignored.
15-
?annotation_with_meta: type ("," extra_info)?
15+
?annotation_with_meta: type ("," optional_info)?
1616

1717

1818
// A type annotation. Can range from a simple qualified name to a complex
@@ -132,9 +132,10 @@ shape: "(" dim ",)"
132132
?dim: INT | ELLIPSES | NAME ("=" INT)?
133133

134134

135-
// Extra meta information added after the docstring annotation, e.g. "optional"
136-
// or "default: 3". Information is dropped and not used to generate stubs.
137-
extra_info: /[^\r\n]+/
135+
// Optional meta information added after the docstring annotation, e.g.
136+
// "optional" or "in range (0, 10), default: 3". Information is dropped and not
137+
// used to generate stubs.
138+
optional_info: /[^\r\n]+/
138139

139140
// A simple name. Can start with a number or character. Can be delimited by "_"
140141
// or "-" but not by ".".

tests/test_docstrings.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def test_literals(self, doctype, expected):
143143
],
144144
)
145145
@pytest.mark.parametrize(
146-
"extra_info",
146+
"optional_info",
147147
[
148148
"",
149149
", optional",
@@ -155,10 +155,10 @@ def test_literals(self, doctype, expected):
155155
", see parameter `image`, optional",
156156
],
157157
)
158-
def test_extra_info(self, doctype, expected, extra_info):
159-
doctype_with_extra = doctype + extra_info
158+
def test_optional_info(self, doctype, expected, optional_info):
159+
doctype_with_optional = doctype + optional_info
160160
transformer = DoctypeTransformer()
161-
annotation, _ = transformer.doctype_to_annotation(doctype_with_extra)
161+
annotation, _ = transformer.doctype_to_annotation(doctype_with_optional)
162162
assert annotation.value == expected
163163

164164
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)