summaryrefslogtreecommitdiff
path: root/astroid/rebuilder.py
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2019-07-09 10:53:54 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2019-07-09 13:05:42 +0300
commit50d53bc61a02e38a0cb272b6d6918741806d1407 (patch)
tree62a4f387673559b510e45a0c9850bede8bb432ca /astroid/rebuilder.py
parent3bee58474a9367826a997b1e760a538a253d71c7 (diff)
downloadastroid-git-50d53bc61a02e38a0cb272b6d6918741806d1407.tar.gz
Introduce a new argument to `Arguments` for storing the positional only annotations
The annotations were stored until now in `.annotations` and `kwonlyargs_annotations`, but given the addition of `posonlyargs`, we need to store the positional only annotations somewhere else as well. This new attribute should simplify the handling of annotations for both positional only and positional or keyword parameters.
Diffstat (limited to 'astroid/rebuilder.py')
-rw-r--r--astroid/rebuilder.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/astroid/rebuilder.py b/astroid/rebuilder.py
index 4cf40097..c480b23d 100644
--- a/astroid/rebuilder.py
+++ b/astroid/rebuilder.py
@@ -225,8 +225,14 @@ class TreeRebuilder:
kw_defaults = []
annotations = []
kwonlyargs_annotations = []
+
+ posonlyargs_annotations = []
if PY38:
posonlyargs = [self.visit(child, newnode) for child in node.posonlyargs]
+ posonlyargs_annotations = [
+ self.visit(arg.annotation, newnode) if arg.annotation else None
+ for arg in node.posonlyargs
+ ]
type_comment_args = [self.check_type_comment(child) for child in node.args]
newnode.postinit(
@@ -237,6 +243,7 @@ class TreeRebuilder:
kw_defaults=kw_defaults,
annotations=annotations,
kwonlyargs_annotations=kwonlyargs_annotations,
+ posonlyargs_annotations=posonlyargs_annotations,
varargannotation=varargannotation,
kwargannotation=kwargannotation,
type_comment_args=type_comment_args,