-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[python] [bug] Fixed handling of dotted module names #2016
[python] [bug] Fixed handling of dotted module names #2016
Conversation
Corresponding fix for server part in #2041. |
@@ -201,12 +201,14 @@ public void processOpts() { | |||
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName); | |||
additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion); | |||
|
|||
// NOTE: The null case can happen during PythonClientOptionsTest.checkOptionsProcessing(). | |||
String packagePath = packageName == null ? "" : packageName.replace('.', File.separatorChar); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be cleaner to have packageName != null during the unit test PythonClientOptionsTest.checkOptionsProcessing
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that would be cleaner, but due to the slightly obscure mocking Kung Fu in the test I was unable to come up with something better.
I propose to land this change as it is (perhaps add a TODO), the current module name handling is totally unusable in non-trivial existing Python projects. Alternatively, somebody could give me a concrete hint how to fix the test... 😉
Tested on a real spec & project, works fine 👍 |
@svenpanne thanks for the PR. What about using the Later we'll create a Python abstract class for Python client and server generators so keeping things a bit more consistent will make the refactoring easier. |
Previously, if you used a packageName of the form "foo.bar.baz", half of the generated files of the python generator went into a subdirectory "foo/bar/baz" (correct), the other half went into a subdirectory "foo.bar.baz" (incorrect).
Good idea, done. Note that I've fixed and improved the corresponding options test a bit, so the funny null check is gone. |
…ols#2016) Previously, if you used a packageName of the form "foo.bar.baz", half of the generated files of the python generator went into a subdirectory "foo/bar/baz" (correct), the other half went into a subdirectory "foo.bar.baz" (incorrect).
PR checklist
./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
and./bin/security/{LANG}-petstore.sh
if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\
. (Irrelevant point, Travis CI checked the PR in my fork.)master
,. Default:3.4.x
,4.0.x
master
.Description of the PR
Previously, if you used a packageName of the form
foo.bar.baz
, half of thegenerated files of the python generator went into a subdirectory
foo/bar/baz
(correct), the other half went into a subdirectoryfoo.bar.baz
(incorrect).@taxpon @frol @mbohlool @cbornet @kenjones-cisco @tomplus @Jyhess