-
Notifications
You must be signed in to change notification settings - Fork 6k
[python-client] Modify python templates to resolve linting errors #6839
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-client] Modify python templates to resolve linting errors #6839
Conversation
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.
These were overriding the real values of modelPackage and apiPackage configurations as specified by user.
Also resulted in not being able to leverage for creating import statements.
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.
Added from server implementation to enable the use of model imports like done within server.
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.
hardcoded models and apis were overriding the values specified by user during configuration.
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.
Resulted in a return statement within a generator which happens when tornado used.
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.
I don't understand it. Who calls deserialize ? This method returns None now.
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.
Resolves the missing use of SSL when using asyncio.
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.
Resolves issue where if the user doesn't specify x-discriminator-value and the key value was always an empty string.
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.
Adds the missing use of ca_certs.
11ebea2 to
b0668f6
Compare
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.
Should it use apiPackage here?
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.
great catch
Overall, the PR looks good to me.
@kenjones-cisco What are the left linter warnings that are not addressed yet? If we squash all the linter messages, we can make linting required to pass CI.
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.
The {{{datatype}}} has to be quoted as it should be a string, otherwise, it generates a broken code.
The remaining ones are because the imports are there but the implementation does not currently exist to use the imported modules. (ie within the api tests generated)
042f49e to
906e0e9
Compare
After the updates recommended and an ignore to handle to difference between python2 vs python3, each client has the same number of lint errors, 120.
120 are unused imports in the generated test modules.
@wing328 Do you happen to know how to fix Travis?
adding /Users/travis/.cocoapods/repos/master to cache
Password:
No output has been received in the last 10m0s, this potentially indicates a stalled build or something wrong with the build itself.
Since the generated tests are just placeholders, I would like to suggest we just drop them from linting altogether (exclude the test folder completely), and enforce linting on CI.
No output has been received in the last 10m0s, this potentially indicates a stalled build or something wrong with the build itself.
@frol I've seen this many times recently. Let me try something out tomorrow to see if that helps.
The linting results for the generated samples are as follows where the first number is the BEFORE and the second is AFTER. pyclient 7714 vs. 120 pyclient3 7717 vs. 120 pyclient3-asyncio 7584 vs. 120 pyclient-tornado 7633 vs. 120 pyclient3-tornado 7633 vs. 120 For the complete details please see the following gist. https://gist.github.com/kenjones-cisco/2eb69a7e8db75e9fd53789f01570d9f2 Enforces linting for python clients by running flake8 for the generated python client.
906e0e9 to
eea711c
Compare
@frol Update the test scripts for python client to run flake8 over the generated python client. petstore_api thereby excluding any files within test/
Looks like all jobs were successful, not sure why Shippable is not updating the status on the PR but the Job says Success when looking at it.
@kenjones-cisco Could you, please, update CI scripts so Python samples get linted automatically and fail if any warning is there? This way we will be sure that we won't shift from the guidelines in future.
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.
Static analysis performed on client as part of CI testing
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.
Static analysis performed on client as part of CI testing
@frol I did update the CI scripts
I just added a review statement for the lines in this PR for the CI scripts.
@kenjones-cisco Great! Thank you for your work!
@wing328 This PR is awesome and it is ready to merge.
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.
It looks like breaking changes. Some libraries embed generated code and use relative imports.
Change apis to api can be a problem too.
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.
The apis to api was actually a bugfix as the default was defined as api but a typo later in the Java code for generating code had a hard coded path of apis.
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.
@wing328 this change broke our use case - we generate code and put it inside our library, so we don't really install swagger generated code itself. so now we get import errors because "swagger_client" is missing
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.
swagger_client is just the default top level package name, as part of the inputs when generating the code you can specify the package name to match the package name you leverage within your code.
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.
current structure:
some_client/swagger_client
some_client/init.py
some_client/client.py - where we import swagger_client stuff
....
change to the name will not fix the problem unfortunately, we need those relative imports :)
@twosigmajab
twosigmajab
Sep 25, 2018
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.
I just opened #8738 to address the need for relative imports
Uh oh!
There was an error while loading. Please reload this page.
PR checklist
./bin/to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.shand./bin/security/{LANG}-petstore.shif 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\.3.0.0branch for changes related to OpenAPI spec 3.0. Default:master.Description of the PR
(details of the change, additional tests that have been done, reference to the issue for tracking, etc)
The linting results for the generated samples are as follows
where the first number is the BEFORE and the second is AFTER.
pyclient 7714 vs. 120
pyclient3 7717 vs. 120
pyclient3-asyncio 7584 vs. 120
pyclient-tornado 7633 vs. 120
pyclient3-tornado 7633 vs. 120
For the complete details please see the following gist.
https://gist.github.com/kenjones-cisco/2eb69a7e8db75e9fd53789f01570d9f2
@taxpon @frol @mbohlool @cbornet
CC @wing328