diff --git a/src/stubber/board/createstubs.py b/src/stubber/board/createstubs.py index 9acc8781..a4fbfd52 100644 --- a/src/stubber/board/createstubs.py +++ b/src/stubber/board/createstubs.py @@ -354,9 +354,8 @@ def write_object_stub( if t in ("str", "int", "float", "bool", "bytearray", "bytes"): # known type: use actual value - # s = "{0}{1} = {2} # type: {3}\n".format(indent, item_name, item_repr, t) - if item_name.upper() == item_name: - s = "{0}{1}: {3} = Final[{2}]\n".format(indent, item_name, item_repr, t) + if item_name.upper() == item_name: # ALL_CAPS --> Final + s = "{0}{1}: Final[{3}] = {2}\n".format(indent, item_name, item_repr, t) else: s = "{0}{1}: {3} = {2}\n".format(indent, item_name, item_repr, t) elif t in ("dict", "list", "tuple"): diff --git a/src/stubber/board/createstubs_db.py b/src/stubber/board/createstubs_db.py index 8f927118..8026a11e 100644 --- a/src/stubber/board/createstubs_db.py +++ b/src/stubber/board/createstubs_db.py @@ -357,9 +357,8 @@ def write_object_stub(self, fp, object_expr: object, obj_name: str, indent: str, if t in ("str", "int", "float", "bool", "bytearray", "bytes"): # known type: use actual value - # s = "{0}{1} = {2} # type: {3}\n".format(indent, item_name, item_repr, t) - if item_name.upper() == item_name: - s = "{0}{1}: {3} = Final[{2}]\n".format(indent, item_name, item_repr, t) + if item_name.upper() == item_name: # ALL_CAPS --> Final + s = "{0}{1}: Final[{3}] = {2}\n".format(indent, item_name, item_repr, t) else: s = "{0}{1}: {3} = {2}\n".format(indent, item_name, item_repr, t) elif t in ("dict", "list", "tuple"): diff --git a/src/stubber/board/createstubs_db_min.py b/src/stubber/board/createstubs_db_min.py index f1ea132a..d72751c9 100644 --- a/src/stubber/board/createstubs_db_min.py +++ b/src/stubber/board/createstubs_db_min.py @@ -155,7 +155,7 @@ def write_object_stub(L,fp,object_expr,obj_name,indent,in_class=0): elif I.startswith(" Final + s = "{0}{1}: Final[{3}] = {2}\n".format(indent, item_name, item_repr, t) else: s = "{0}{1}: {3} = {2}\n".format(indent, item_name, item_repr, t) elif t in ("dict", "list", "tuple"): diff --git a/src/stubber/board/createstubs_mem_min.py b/src/stubber/board/createstubs_mem_min.py index 8d53c24a..b35cae10 100644 --- a/src/stubber/board/createstubs_mem_min.py +++ b/src/stubber/board/createstubs_mem_min.py @@ -151,7 +151,7 @@ def write_object_stub(L,fp,object_expr,obj_name,indent,in_class=0): elif I.startswith(" None:", class_line + 1) assert class_line < LSB_line < init_line, "Literals MUST be listed before class methods"