"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "pylint/pyreverse/utils.py" between
pylint-2.17.5.tar.gz and pylint-2.17.6.tar.gz

About: pylint analyzes Python source code looking for bugs and signs of poor quality.

utils.py  (pylint-2.17.5):utils.py  (pylint-2.17.6)
skipping to change at line 190 skipping to change at line 190
pass pass
else: else:
return ann return ann
try: try:
default, *_ = node.infer() default, *_ = node.infer()
except astroid.InferenceError: except astroid.InferenceError:
default = "" default = ""
label = get_annotation_label(ann) label = get_annotation_label(ann)
if ann:
label = ( if (
rf"Optional[{label}]" ann
if getattr(default, "value", "value") is None and getattr(default, "value", "value") is None
and not label.startswith("Optional") and not label.startswith("Optional")
else label and (
not isinstance(ann, nodes.BinOp)
or not any(
isinstance(child, nodes.Const) and child.value is None
for child in ann.get_children()
)
) )
if label: ):
label = rf"Optional[{label}]"
if label and ann:
ann.name = label ann.name = label
return ann return ann
def infer_node(node: nodes.AssignAttr | nodes.AssignName) -> set[InferenceResult ]: def infer_node(node: nodes.AssignAttr | nodes.AssignName) -> set[InferenceResult ]:
"""Return a set containing the node annotation if it exists """Return a set containing the node annotation if it exists
otherwise return a set of the inferred types using the NodeNG.infer method. otherwise return a set of the inferred types using the NodeNG.infer method.
""" """
ann = get_annotation(node) ann = get_annotation(node)
try: try:
 End of changes. 2 change blocks. 
7 lines changed or deleted 15 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)