-
Notifications
You must be signed in to change notification settings - Fork 12
Automatic modernization (Python 2.x to Python 3.x) and formatting of legacy python code. #49
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
base: main
Are you sure you want to change the base?
Automatic modernization (Python 2.x to Python 3.x) and formatting of legacy python code. #49
Conversation
modernize --no-diffs --no-six -wnj 8 $(ruff check --show-files)
`ruff format --target-version py37 --preview` Also, some manual fixes for identation issues in legacy
`ruff check --fix --target-version py37 --preview`
|
Hello, @SaelKimberly! We are glad to see your contribution! Python 2 reached EOL 5 years ago. As far I understand, you've checked the possibility to make cluster and proceed basic cluster operations. Let's run it on our CI. For this purpose, I ask you to separate code linting to including in the further patch. It helps us to concentrate on functional changes first. Can you make it? The next step is expanding the test suite by running more tests. At least @concourse_cluster tests should be brought up. We'll plan this work, but the similar help are welcome. Suggested by you changes require modification not only in the core part of Greengage but in the user third-party utilities. E.g.: utilities that use built-in gppylib for cluster connection. So we need some time to collect feedback from other users about these changes. In case of success, we'll be able to integrate this patch past November, taking in account internal working plan. PS. Also, please reword the ticket description in English, to make this discussion available for everyone. |
|
Hello, @Stolb27! I have not built yet GreengageDB with these changes. This PR is, first and foremost, proof of the fundamental possibility of automatic code migration (99.9% of code changes took less than 1 minute). |
So let's concentrate on this task to collect troubles after auto-migration.
Is it really a required step to check migration possibility? Does it replace python2-specific code with more generic? But it increases patch footprint significantly. For example, I've checked the 1st patch locally and got the next errors: It seems that old pygresql 4.0 is incompatible with python 3. |
|
I see. As in PyPi docs of And also, in docs Maybe, I don't know, version 4 of pygresql is a little bit outdated... I think there are definitely no live packages for Python that require Python 2 to run, except for the really rare, battle-tested ones. PyGreSQL is certainly battle-tested, but the Python 2 requirement is also probably a security issue, and proof that the mammoths are alive. Unless you're using Postgres 9 here, then I really agree it's may be necessary. In this case, of course, it is worth bypassing this package when migrating code. |
Greengage main branch contains gpdb 6 code base. That is based on Postgres 9.4. So the first step that we should do before accepting this patch is updating pygresql version or replacing it with other lib (e.g. psycopg2 as was made in gpdb 7). Currently, we work under test automation to migrate Greengage 7 development to this repo too. Greengage 7 was already migrated to python 3. |
|
|
I am currently in the process of researching the possibility of updating the PyGreSQL library to version 5.2.5 and I have encountered the following incompatibilities:
|




Hello everyone!
Perhaps, as part of a real modernization of the code base, it is worth introducing the use of Ruff as a linter and formatter for python code.
And move once and for all from python2 (dead for many years) to python3 (ideally 3.9+, since older ones are no longer supported by the community).
This PR is an attempt to automatically (by 99.9%) migrate to more or less modern code.
If it takes off, you can add checks for known errors and formatting problems to CI before building:
ruff check --silent --target-version py37 --select <error codes>ruff format --check --silent --target-version py37Here are some reminders before you submit the pull request
make installcheck