two imports with the same import-name are not distinguised
See original GitHub issueDescribe the bug I am not yet sure how to reproduce which state, as I have two different observation:
Example 1:
Generated code:
from ...apimachinery.pkg.apis.meta import v1
from ..core import v1
Example 2:
Generated code:
from ...apimachinery.pkg.apis.meta import v1
from ..core import v1 as v1_1
In this example, the second import is renamed to avoid the collision but the references are not. Resulting in code trying to access module members that are in v1_1
but refer to v1
. (Example)
Expected behavior
The second example is a step in the right direction (or maybe import more of the package name, in this example meta.v1
instead of just v1
). But the references must be updated.
Version:
- datamodel-code-generator: git master
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
Change Name of Import in Java, or import two classes with the ...
You cannot import two classes with the same name and use both of them unqualified. Import one class and use the fully qualified...
Read more >Can python distinguish two different functions defined ... - Quora
Can python distinguish two different functions defined with the same name but imported from different modules?
Read more >Absolute vs Relative Imports in Python
A relative import specifies the resource to be imported relative to the current location—that is, the location where the import statement is. There...
Read more >5. The import system — Python 3.11.1 documentation
When a module is first imported, Python searches for the module and if found, ... re-import the named module, the two module objects...
Read more >Chapter 7. Packages and Modules - Oracle Help Center
If two single-type-import declarations in the same compilation unit attempt to import types with the same simple name, then a compile-time error occurs,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey @koxudaxi
thanks!
I tested against current master. Looks good!
(It looks like you didn’t publish to pypi though)
This is strange. I had the following error with
poetry
:Not sure what I did wrong, but is working now!