Implement the ability to generate stubs for top-level JPackage(name) type calls
4 unresolved threads
Useful for code such as that in PyJapc and other JPype using libraries, which can't use the imports mechanism.
Merge request reports
Activity
97 102 98 103 log.info(f'Collected {len(packages)} packages ...') 99 104 105 # Map package names to a list of direct subpackages 106 # (e.g {'foo.bar': ['boo.bar.wibble', 'foo.bar.wobble']}). changed this line in version 2 of the diff
109 125 initFile = submodulePath / '__init__.pyi' 110 126 initFile.touch() 111 127 112 generateStubsForJavaPackage(pkg, submodulePath / '__init__.pyi') 128 generateStubsForJavaPackage(pkg, submodulePath / '__init__.pyi', subpackages[pkg.__name__]) 129 130 if jpypeStubs: 131 tld_packages = [name for name in subpackages if '.' not in name] Well, it is possible, if
parentPackages
passed intogenerateJavaStubs()
contains non-root packages, likecern.lsa
. The internal resolution will recursively find all subpackages likecern.lsa.client
,cern.lsa.client.spi
etc., but the root packagecern
will never show up in the list.What I would do: partition at the first '.', then build a set...
changed this line in version 2 of the diff
82 84 log.warning(f'skipping {package.__name__}.{name}: {e}') 83 85 84 86 85 def generateJavaStubs(parentPackages: List[jpype.JPackage], useStubsSuffix: bool = True, 86 outputDir: Union[str, pathlib.Path] = '.') -> None: 87 def generateJavaStubs(parentPackages: List[jpype.JPackage], 88 useStubsSuffix: bool = True, 89 outputDir: Union[str, pathlib.Path] = '.', 90 jpypeStubs: bool = True, changed this line in version 2 of the diff
- Resolved by Philip Elson
202 256 classOutput.append('') 203 257 generateEmptyClassStub(missingPrivateClass, classesDone=classesDone, output=classOutput) 204 258 205 if any(('typing.' in line) for line in classOutput): 206 importOutput.append('import typing') 259 classesInModule = [className for className in classesDone if '$' not in className] changed this line in version 2 of the diff
- Resolved by Philip Elson
added 1 commit
- ac3c1709 - Restructure the code based on the review comments.
added 1 commit
- 6eae55e2 - Restructure the code based on the review comments.
- Resolved by Philip Elson
- Resolved by Philip Elson
- Resolved by Philip Elson
mentioned in commit 2214f35d
Please register or sign in to reply