Skip to content

[python-flask] adopt python3.5+ syntax#16375

Merged
wing328 merged 3 commits intoOpenAPITools:masterfrom
anis-campos:python_flask/remove_python_2
Aug 23, 2023
Merged

[python-flask] adopt python3.5+ syntax#16375
wing328 merged 3 commits intoOpenAPITools:masterfrom
anis-campos:python_flask/remove_python_2

Conversation

@anis-campos
Copy link
Copy Markdown
Contributor

@anis-campos anis-campos commented Aug 21, 2023

removing some residual python2 code, since it is not supported anymore, like:

  • no need for six anymore
  • no need for encoding utf8 in top file
  • remove object inheritance in base model
  • remove absolute import __future__

resolve #16377

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    For Windows users, please run the script in Git BASH.
  • In case you are adding a new generator, run the following additional script :
    ./bin/utils/ensure-up-to-date
    
    Commit all changed files.
  • File the PR against the correct branch: master (6.3.0) (minor release - breaking changes with fallbacks), 7.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@anis-campos anis-campos changed the title adopt python3.5+ syntax [python-flask] adopt python3.5+ syntax Aug 21, 2023
@wing328
Copy link
Copy Markdown
Member

wing328 commented Aug 21, 2023

FYI. I've filed #16321 to add better pydantic support in the python fastapi generator. Do you think python-flask generator also needs similar enhancement (python flask generator does not use pydantic at the moment if I remember correctly) ?

removing some residual python2 code, since it is not supported anymore, like:
- no need for `six` anymore
- no need for encoding utf8 in top file
- remove `object` inheritance in base model
- remove absolute import `__future__`
@anis-campos
Copy link
Copy Markdown
Contributor Author

anis-campos commented Aug 22, 2023

FYI. I've filed #16321 to add better pydantic support in the python fastapi generator. Do you think python-flask generator also needs similar enhancement (python flask generator does not use pydantic at the moment if I remember correctly) ?

I'm not a user of pydantic, we generally use marshmallow and dataclasses in our projects, so I can't really tell the pros and cons, but I will look up to it, it may do some good for us.

However, I'm not sure that adding support for pydantic in the flask generator at this point is really wise. IMO, I would rather have it in another generator, or alternatively, it should be a choice at generation time, not sure how it would pan out, but it would certainly be a breaking change for those already using it.

@wing328
Copy link
Copy Markdown
Member

wing328 commented Aug 22, 2023

thanks for the feedback. we won't add it to the python flask generator for the time being.

Anis Campos added 2 commits August 22, 2023 14:16
applying the new templates
ignore all the `.venv` folders
@anis-campos anis-campos marked this pull request as ready for review August 22, 2023 12:35
@wing328 wing328 added this to the 7.0.0 milestone Aug 22, 2023
@wing328
Copy link
Copy Markdown
Member

wing328 commented Aug 23, 2023

LGTM. Thanks for the PR.

FYI @taxpon (2017/07) @frol (2017/07) @mbohlool (2017/07) @cbornet (2017/09) @kenjones-cisco (2017/11) @tomplus (2018/10) @arun-nalla (2019/11) @krjakbrjak (2023/02)

@wing328 wing328 merged commit 00de163 into OpenAPITools:master Aug 23, 2023
@anis-campos anis-campos deleted the python_flask/remove_python_2 branch August 23, 2023 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REQ] Improve python-flask code syntax

2 participants