-
Couldn't load subscription status.
- Fork 15
Initial Python3 support with Test-Driven-Development enforced by CI (with git diff coverage and diff lint checking) + mypy, pyre and pytype #27
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
Merged
bernhardkaindl
merged 33 commits into
xenserver:master
from
xenserver-next:py3-move-to-tox
May 9, 2023
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Apply "Use of `unicode` needed to be immediately handled" by Yann. Reserved "but a few checks relying on `str` could become insufficient in python2 with the larger usage of unicode strings." for applying optionally these not-needed later, because they could change behavior and if needed, they would belong to these other commits. And, after 21 commits from Yann and my work on to of that, that didn't appear. Co-authored-by: Yann Dirson <yann.dirson@vates.fr> Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
…conversion Signed-off-by: Yann Dirson <yann.dirson@vates.fr>
…s to open() as ths is considered best practice. (cherry picked from cpython commit 6cef076ba5edbfa42239924951d8acbb087b3b19) Signed-off-by: Brett Cannon <bcannon@gmail.com>
…fication Signed-off-by: Yann Dirson <yann.dirson@vates.fr>
…ated Signed-off-by: Yann Dirson <yann.dirson@vates.fr>
Running tests on python3 did reveal some of them. Signed-off-by: Yann Dirson <yann.dirson@vates.fr>
Signed-off-by: Yann Dirson <yann.dirson@vates.fr>
There is no guaranty about ordering of dict elements, and tests compare results derived from enumerating a dict element. We could have used an OrderedDict to store the formulae and get a predictible output order, but just considering the output as a set seems better. Only applying this to rules expected to hold more than one element. Signed-off-by: Yann Dirson <yann.dirson@vates.fr>
Caught by extended test. Signed-off-by: Yann Dirson <yann.dirson@vates.fr>
This goes away in python3. Signed-off-by: Yann Dirson <yann.dirson@vates.fr>
hashlib came with python 2.5, and old md5 module disappears in 3.0 Originally by Yann Dirson, changed to not add .encode() for md5 creation, because encoding changes are dealt with in other commits. Co-authored-by: Yann Dirson <yann.dirson@vates.fr> Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
Signed-off-by: Yann Dirson <yann.dirson@vates.fr>
Signed-off-by: Yann Dirson <yann.dirson@vates.fr>
Reported under python3 for members created on-the-fly in `setUp()` Signed-off-by: Yann Dirson <yann.dirson@vates.fr>
be96bba to
48b21c3
Compare
psafont
reviewed
May 4, 2023
48b21c3 to
ca69f11
Compare
Codecov Report
@@ Coverage Diff @@
## master #27 +/- ##
=========================================
Coverage ? 69.00%
=========================================
Files ? 20
Lines ? 3420
Branches ? 0
=========================================
Hits ? 2360
Misses ? 1060
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. |
Originally by Yann Dirson: With python3, pylint complains about `else: raise()` constructs. This rework avoids them and reduces cyclomatic complexity by using the error-out-first idiom. Minor related update by Bernhard Kaindl: .coveragerc: Don't complain if tests don't hit ValueError(pciids.txt) tests/test_pci.py covers this code except for the ValueError() lines. In .coveragerc, we already declare that coverage shall not complain about missing coverage on raising AssertionError and raise NotImplementedError, we do not expect to have to trigger "raise ValueError()" in general, so add ValueError() to the list. Signed-off-by: Yann Dirson <yann.dirson@vates.fr> Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
This is supposed to be just a module renaming to conform to PEP8, see https://docs.python.org/3/whatsnew/3.0.html#library-changes The SafeConfigParser class has been renamed to ConfigParser in Python 3.2, and backported as addon package. The `readfp` method now triggers a deprecation warning to replace it with `read_file`. Originally authored by Yann Dirson, Updated by Bernhard Kaindl to no longer need the WIP marker, to unblock the Python3 work, with more tests to be added. Co-authored-by: Yann Dirson <yann.dirson@vates.fr> Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
xcp.xmlunwrap extracts XML Elements from XML, and for Python2, the unwrapped unicode is encoded into Py2:str(bytes). Python3 unwraps XML Text elements as the Py3:str type which is likewise Unicode, but since Py3:str is the native type, we don't want to encode the Py3:str to Py3:bytes as that would break the API for use on Python3. BEcause binary data is not legal XML content and XML Text elements are defined to be encoded text, UTF-8 is the standard encoding, which Python converts to. It this fine to only encode() to Py2:str(=bytes) on Python2 as a legacy operation which can be removed once we drop Python2. Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
This is and update of the older commit "xcp.accessor: upgrade urllib usage (futurize)" by Yann Dirson, it reuses the changes from futurize and uses six.moves instead: To update xcp/accessor.py's use of urllib to Python3, Yann's Py3 PR originally used import future.standard_library.install_aliases(), which had several drawbacks: - Forced a new dependency on the future module - The future module is no longer updated and is using deprecated code - future.standard_library.install_aliases() imports imp - the 'import imp' itself triggers a deprecation warning - imp is slated for for removal with Python 3.12(might be later tough) - and it required him adding several pylint suppression comments - because future.standard_library also has no type markers, not using future but six.moves (which is also much shorter) also allows to use mypy without having the add additional warning suppressions. Further, using future would be inconsistent with Yann's existing Un-futurize in this commit: "Un-futurize: replace future.utils.raise_ with six.raise_from" So fully skip the future dependency and fix the deprecation warning by using six like Yann did in the commit above as well. Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
ca69f11 to
b4e3aa0
Compare
psafont
reviewed
May 9, 2023
psafont
approved these changes
May 9, 2023
6da737c to
421b4f7
Compare
Without these generated API descriptions, we'd have to disable all checks which use these APIs because we'd have to typing info for them. Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
…n-not-iterating Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
421b4f7 to
ec8e917
Compare
Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
ec8e917 to
5110074
Compare
rosslagerwall
approved these changes
May 9, 2023
This was referenced May 9, 2023
Closed
bernhardkaindl
added a commit
to xenserver-next/python-libs
that referenced
this pull request
Jun 7, 2023
Fixup the unclosed file warning which was introduced by commit 08f000 (xcp.repository: switch from ConfigParser to configparser) in xenserver#27. PS: Because I'm using pre-commit now, also remove a line which had trailing spaces Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
bernhardkaindl
added a commit
that referenced
this pull request
Jun 9, 2023
…le-warning xcp/repository.py: Fixup unclosed file warning left from #27
This was referenced Jun 9, 2023
bernhardkaindl
added a commit
to rosslagerwall/python-libs
that referenced
this pull request
May 8, 2024
…/add-sar-system-load-testcase Add system load testcase to check collecting sar output, improve verification code
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I have worked on @ydirson's PR #17 and think that my work on it should be ready now.
With this PR, Python3 support is not 100% complete yet, but with all tests passing for Python3 and all non-whitespace changes covered by code coverage, it's a big leap forward.
Warnings and further bugs remain, but they have to be fixed in my other PRs!
The summary of reviews done so far is: It's fine, and I shall update the CodeCov upload to upload code coverage for Python2.7 and Python3 separately, but I can do this in a followup PR, no problem for now:
Initial Python3 support with Test-Driven-Development enforced by CI:
Initial Python3 support with Test-Driven-Development enforced by CI:
mypy,pyreandpytypeGitHub CI (but also local CI checks) that any changes (besides white space-only diff lines):
pylintwarning type which is not disabled inpylintrcmypy,pyre, andpytype.Documentation on setting up local CI using tox and more is in README.md.
Follow-up: