Bug 432688 - Python code generator does not add typehints
Summary: Python code generator does not add typehints
Status: RESOLVED FIXED
Alias: None
Product: umbrello
Classification: Applications
Component: exporter (show other bugs)
Version: 2.33.1 (KDE releases 20.12.1)
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Umbrello Development Group
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-02-09 12:59 UTC by patrick
Modified: 2022-02-15 05:54 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 2.33.80 (KDE releases 22.03.80)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description patrick 2021-02-09 12:59:07 UTC
Python code that is generated does not include typehints
ref: https://docs.python.org/3/library/typing.html

STEPS TO REPRODUCE
1. Create UML diagram
2. Export code as python

OBSERVED RESULT
The functions will not have typehint
`def create(self, videoStreamInformation):`


EXPECTED RESULT
Code with typehint
`def create(self, videoStreamInformation: VideoAndStreamInformation):`

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: arch 5.10.12-arch1-1
KDE Plasma Version: 5.20.5
KDE Frameworks Version: 5.78.0
Qt Version: 5.15
Comment 1 patrick 2021-02-09 12:59:26 UTC
I'm working on it: https://invent.kde.org/sdk/umbrello/-/merge_requests/22
Comment 2 Oliver Kellogg 2021-12-23 00:56:30 UTC
Git commit 5b860d44d97ea011a943bfed80e58f9c62dbd354 by Oliver Kellogg.
Committed on 23/12/2021 at 00:55.
Pushed by okellogg into branch 'master'.

https://invent.kde.org/sdk/umbrello/-/merge_requests/22

Apply outstanding changes from fix_argument_type_python3 branch of
                    https://invent.kde.org/patrickpereira/umbrello :

umbrello/codegenerators/python/pythonwriter.{h,cpp}
- Add functions fixTypeName, findIncludeFromType.

umbrello/codegenerators/python/pythonwriter.cpp
- In function writeClass,
  - in loop over includes use new function findIncludeFromType to avoid
    including Python predefined classes;
  - on printing superclasses omit inheritance from `object' (not needed
    in python3).
- In function writeOperations loop over opList nested loop over atl use
  new function fixTypeName on at->getTypeName() to make the types
  compatible with Python.

M  +86   -11   umbrello/codegenerators/python/pythonwriter.cpp
M  +3    -0    umbrello/codegenerators/python/pythonwriter.h

https://invent.kde.org/sdk/umbrello/commit/5b860d44d97ea011a943bfed80e58f9c62dbd354
Comment 3 Oliver Kellogg 2022-02-15 05:54:06 UTC
Git commit 5ed8d6bdb9bb04fe39645096d43cbea7e437d202 by Oliver Kellogg.
Committed on 15/02/2022 at 05:53.
Pushed by okellogg into branch 'master'.

umbrello/codeimport/pythonimport.cpp function parseMethodParameters : Add support for type hints.
Related: bug 449462

M  +35   -17   umbrello/codeimport/pythonimport.cpp

https://invent.kde.org/sdk/umbrello/commit/5ed8d6bdb9bb04fe39645096d43cbea7e437d202