enthought/comtypes

Remove `for_stub=True` conditional branch from the `tools.codegenerator.ImportedNamespaces.getvalue`

junkmd opened this issue · 0 comments

THIS IS FOR drop_py2 PLAN! Please see #392.

The ImportedNamespaces is a "sprout class" that generates import parts strings of comtypes.gen._xxxxxxxxxxxx_xxxxxxxx_xxxxxxxx_xxxxxxxxxxxxxxxxxxxxx_x_x_x.

In the past, an optional argument for_stub is added to the getvalues method, since we were trying to add the functionality to generate type stubs at the same time as the executable module under the comtypes.gen(#355).

def getvalue(self, for_stub=False):

However, as you can see in #400, the plan has been revised and type hints will be added to executable modules with inline annotations as part of the drop_py2 plan.

So it is no longer necessary to take a for_stub argument or conditional branch based on it.

Also, the following doctests are no longer required.

>>> print(imports.getvalue(for_stub=True))
from ctypes import *
import datetime
from decimal import Decimal as Decimal
from comtypes import (
BSTR as BSTR,
CoClass as CoClass,
COMMETHOD as COMMETHOD,
dispid as dispid,
DISPMETHOD as DISPMETHOD,
DISPPROPERTY as DISPPROPERTY,
GUID as GUID,
IUnknown as IUnknown,
)
import ctypes.wintypes

Before PR, run python -m doctest -v comtypes/tools/codegenerator.py and make sure the test passes.