Skip to content

A python script which creates an improved unreal module stubfile for better type annotation and autocompletion

License

Notifications You must be signed in to change notification settings

matthijsjanssens/UE4-PythonStubImproved

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

UE4 Python Stub Improvements

A python script which creates an improved Unreal module stub file for better type annotation and auto-completion.

image

Usage

Generating the Stub File

Set script as a Python Startup script in the Unreal Editor Project Settings and enable Python Developer Mode in the Editor or Project Settings. Restart the Editor (twice if Developer Mode wasn't enabled yet) and find the improved Python Stub file in .../Your-UE4-Project/InterMediate/PythonStubImproved/unreal.py

Adding it to Visual Studio Code

Add the following workspace setting:

{
    "python.defaultInterpreterPath": "C:/Program Files/Epic Games/UE_4.27/Engine/Binaries/ThirdParty/Python3/Win64/python",
    "python.analysis.stubPath": "C:/Repositories/Your-UE4-Project/Intermediate/PythonStubImproved/"
}

Current State

  • 3441 return type annotations have been corrected
  • List.cast(Class, []) is turned into List[Class]()
  • Map.cast(KeyClass, ValueClass, {}) is turned into Dict[KeyClass, ValueClass]()
  • Set.cast(Class, []) is turned into {Class()}
  • DEBUG constant can be set to True to highlight before and after changes by commenting out the original code (look for # --).

Todo

  • Fix function argument type annotation (currently often Unknown)
  • Support for multiple python versions (currently tested on 3.7.7 and relying on the typing module)
  • Extend Unreal classes to expose Editor Properties directly

About

A python script which creates an improved unreal module stubfile for better type annotation and autocompletion

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published