-
Notifications
You must be signed in to change notification settings - Fork 155
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 3.12 compat #463
Python 3.12 compat #463
Conversation
When checking the root in a UnixFlavour system, it is / for an absolute path, and '' for a relative one, and unix systems have no drive. For artifactory, if we consider the drive to be "http://b/artifactory" and root to be "/", it behaves exactly like Windows and Unix Flavours, and no if's and exceptions to handle the root are needed in the code. This refactor makes the migration to python 3.12 much easier, since we can subclass pathlib.Path directly and we don't need to override as many methods. Notice: This is a breaking change if you are accessing the `root` property directly, but I'm assuming that mostly everyone should be using the `repo` accessor for that. There is also some minor changes in leading/trailing slashes
Also, if tox is installed with python3.12, some pre-commit plugins didn't work, so I have updated those.
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.
May be insted of defining many "if" across code, we can do something like inheretance (or even duplicating classes
_ArtifactoryPath(...):
... # define <3.11 and comment why it's this way
_ArtifactoryPath311(_ArtifactoryPath):
... # define <3.11 and comment why it's this way
BaseClass = _ArtifactoryPath if IS_PYTHON_3_12_OR_NEWER else _ArtifactoryPath311
ArtifactoryPath(BaseClass)
This way when 3.11 ends it's lifecycle (31 Oct 2027) - we can just remove the whole _ArtifactoryPath311
and keep using new version
So the idea is to move all 3.11 related code to a separate class and add new things to 3.12 class (but we can name it as regular class, 312
not required in it's name, because it'll be only class soon)
This commit addresses the concerns raised in the Pull request. It helps minimize the amount of changes (way less indentation) compared to master. Also, used a single constant for marking code that will be removed once 3.11 is deprecated. This commit likely should be "merged" into the previous two once the PR review process is over. And if not, well, you have this nice comment here forever :)
Hi, I think I've addressed all changes requested by @allburov (and that simplified the diff quite a bit, thank you for that). Please let me know if there is anything else I can do, happy to help. Otherwise, just waiting to see if @beliaev-maksim can provide his input in the "breaking changes" conversation. Thank you for your time! |
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.
That's a good work and research, thank you! 🫶
Let's wait for some feedback from the community, and merge if it's good one!
I personally don't use the project anymore so don't have anything to test :(
Let's set a deadline - 21 January 2025. If no critical bugs found before that date - we'll merge #463 and make a release 🚀 |
I can provide some data using a minimal example:
¹ 46728f6 which includes this PR Python 3.12 is fixed 👍. Python 3.13 still fails, but with a different error as reported in #430. I'm going to file a new issue for 3.13 compatibility. Update: #470 |
@offa thank you for the feedback! |
Hi,
I took a stab at addressing #430, let me describe a little bit the changes because it ended up being a larger PR than what I intended.
The PR is split in 3 commits:
Why did I have to make a breaking change
First, I tried just upgrading to python 3.12 and working around the changes done in
pathlib.PurePath
, but I was having to copy/paste and slightly tweak a lot of methods because of the choice of using the first part of the path as the "root".An example of what I mean:
This is because the second path doesn't have a root, but IMO this is a relative path.
So, to fix that I've made the first commit, which is changing in python3.11 and before the way the root is handled. This is how the behavior changes, and that may be a BREAKING change, so I am not sure if that is acceptable or not.
I think this may not be so bad, since most of the interface is internal. If a code is using
ArtifactoryPath.root
this will change, if it is usingArtifactoryPath.repo
it is backwards compatible.Final comments
After that change, the migration was much easier. Commit 2 is making the code work in python3.12, and commit 3 is making it work at the same time in python3.12 AND in older python versions.
There are some small changes in precommit files that I had to do to make sure they would work when tox is invoked under python3.12, but I can drop those if needed, or open a separate PR.
Last thing: All unit tests pass, but I couldn't get a trial license to integration test those changes, so I didn't run that, sorry.
Let me know if I can do anything to help the review!