You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a python developer I want to use a COM client to develop a tool automation / tool integration. With C++ and .NET I have support for type checking and language server support.
As python developer the type inspection only works at runtime. It would be good to be able to use newer technologies like python type hinting and static type checkers like mypy.
In tool chain scenarios it might be wise to pack mulitple stubs / implementations into (hierarchical) packages. Hence the packaging should be available. The package should be selectable, either a namespace package or a classic package.
The difference lies in the different implementation of the init.py in the files.
Planned implementation
Command-line
It is planned to add a new export command: tlb2pyi
The following options will apply:
--package
A (dot-separated) python package name (defaults to assembly file name)
--shared-file-name
The name of the shared file (defaults to the assembly file name with dots replaced by underscores)
--support-namespace
A boolean flag to support namespace packages (defaults to assembly file name contains a dot)
--output-dir
The output directory to use (defaults to .)
assembly
The dll to dump
Other arguments might be added on requirement.
Implementation
The assembly will be loaded into the context.
For each class flagged with ProgId, a python class will be created inheriting from Dispatch. In addition, a get_ method will be created where Camel Case will be transformed to lower snake case.
All classes, value types, enums and interfaces will be dumped to the shared file.
Enums will derive from enum.IntEnum. Interfaces will be implemented as Protocols. Only public, ComVisible, Non-abstract classed will be exported to type stubs.
Mapping of .NET Types to Python types:
string: str
int: int
short: int (maybe annotated)
sbyte: int (maybe annotated)
long: int (maybe annotated)
uint: int (maybe annotated)
ushort: int (maybe annotated)
byte: int (maybe annotated)
ulong: int (maybe annotated)
float: float
double: float
Guid: TBD
Array: collections.abc.Collection (sized, iterable, container)
List: list
Dictionary: Mapping
Other types: TBD
Limitations
The pystub generator in its first implementation will only consider self-contained assemblies without related TLBs.
The text was updated successfully, but these errors were encountered:
What is the goal of this request?
As a python developer I want to use a COM client to develop a tool automation / tool integration. With C++ and .NET I have support for type checking and language server support.
As python developer the type inspection only works at runtime. It would be good to be able to use newer technologies like python type hinting and static type checkers like mypy.
Example C# interface.
Consider the following interface:
Feature: Python Dispatch
With this getting into mind, the following python class should be available:
Feature: Python Stub Interfaces
In order to be able to check my python code against static python type hints, I need python stub interfaces:
Feature: Packaging
In tool chain scenarios it might be wise to pack mulitple stubs / implementations into (hierarchical) packages. Hence the packaging should be available. The package should be selectable, either a namespace package or a classic package.
Example: classic package
Example: namespace package
The difference lies in the different implementation of the init.py in the files.
Planned implementation
Command-line
It is planned to add a new export command: tlb2pyi
The following options will apply:
--package
A (dot-separated) python package name (defaults to assembly file name)
--shared-file-name
The name of the shared file (defaults to the assembly file name with dots replaced by underscores)
--support-namespace
A boolean flag to support namespace packages (defaults to assembly file name contains a dot)
--output-dir
The output directory to use (defaults to .)
assembly
The dll to dump
Other arguments might be added on requirement.
Implementation
The assembly will be loaded into the context.
For each class flagged with
ProgId
, a python class will be created inheriting from Dispatch. In addition, a get_ method will be created where Camel Case will be transformed to lower snake case.All classes, value types, enums and interfaces will be dumped to the shared file.
Enums will derive from
enum.IntEnum
. Interfaces will be implemented asProtocols
. Only public, ComVisible, Non-abstract classed will be exported to type stubs.Mapping of .NET Types to Python types:
string: str
int: int
short: int (maybe annotated)
sbyte: int (maybe annotated)
long: int (maybe annotated)
uint: int (maybe annotated)
ushort: int (maybe annotated)
byte: int (maybe annotated)
ulong: int (maybe annotated)
float: float
double: float
Guid: TBD
Array: collections.abc.Collection (sized, iterable, container)
List: list
Dictionary: Mapping
Other types: TBD
Limitations
The pystub generator in its first implementation will only consider self-contained assemblies without related TLBs.
The text was updated successfully, but these errors were encountered: