-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
[wip] Future/pathlib - make used path type configurable #2230
[wip] Future/pathlib - make used path type configurable #2230
Conversation
self._parser.addini('pathtype', 'path implementation to be used', default='pylib') | ||
|
||
self.invocation_dir = self.make_path() | ||
self.rootdir = self.make_path(self.rootdir) |
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.
Unfortunately this would break all plugins which use this; then users are in the unfortunate situation where they can't make use of this feature because it breaks some of their plugins, and plugin authors will have to support both APIs in order to satisfy all users...
On the other hand I don't have any idea on how to solve this. 😞
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.
this is why this will be and opt-in and will support a transitional api for quite a while
however py.path has to die
the starting point in any case is compatibility wrappers and the ability to switch
only after all major plugins support the transition apis we can take a look at switching the default
this is something that will have a transition period way beyond the lifetime of python 2
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.
this is why this will be and opt-in and will support a transitional api for quite a while
this is something that will have a transition period way beyond the lifetime of python 2
Oh OK that seems sensible, and as soon as we add an alternative the better. But what do you mean by a "transitional API" exactly? What you did here or something else entirely like a py.local subclass which supports
pathlib.Path` methods?
however py.path has to die
Yeah, it had its purpose of course but with pathlib
on standard library it doesn't make sense to maintain it in the long run.
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 didnt even start with a transitional api - whats in here right now is just the opt in to change
my next steps wil lbe to experiment wit the transition
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.
Got it, thanks
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.
Would it be simpler to add a new fixture and deprecate the tmpdir
one? How many other places is py.path.local exposed?
So I assume you also looked at making py.path.local follow the __fspath__
protocol from PEP 519 and that it's not sanely doable?
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.
How many other places is py.path.local exposed?
Unfortunately in quite a lot of places, for example the fspath
attribute of test items, config.rootdir
and config.inifile
come to mind.
So I assume you also looked at making py.path.local follow the fspath protocol from PEP 519 and that it's not sanely doable?
That's an interesting idea, although I'm not sure if that would help us reach the ultimate goal which is to drop py.path.local
altogether... at least that's what I thought the ultimate goal was.
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.
fspath is already supported, but the api differs
closing, i no longer believe the approach is sustainable |
for future reference - id like to completely switch the internals to pathlib/pathlib2 |
You and me both! For the record that was not even a possibility when I would like to debate on how to replace |
new attribute names for everything the py.path attributes can stay for years, we can literally put the attributes into mixins for app elements and put those into a module waiting for deletion additionally we might needthme for new objects for a while |
As an alternative approach, what about making this part of pytest |
This would literally break almost every test suite that uses pytest. Imagine: any test which uses I imagine if we ever do that, nobody would ever update pytest in old suites, people would only use the new version with new test suites (if at all TBH). |
True it would be a PITA to do the change; but in practice, the locations of the changes needed are fairly self-documenting and you have a good test suite pointing when all is good. So upgrading wouldn't be that much pain I believe. I'm always a bit hesitant to use the pytest paths because the API is kinda undocumented and unofficial. In many of my tests lately, I started wrapping them inside a pathlib at boundary place. Okay so alternative approach; opt-in via a flag? Internally we can migrate all to pathlib; if the flag is set we just transform it at boundary level (e.g. return value of the fixture) to legacy py.path? |
You are right that the breakage would be easy to spot if you have a good test suite. The problem is the sheer amount of test suites that companies have for example. At work we have easily 100+ test suites and easily 60k+ tests, it is a huge PITA to fix all this and really hard to sell that is worth the hassle.
Unfortunately plugins also use same API. If a plugin uses |
In theory, we know all plugins (because they need to register themselves). So we could keep sending the old API to all legacy plugins, and the new one to who upgrade their plugins. It should not be hard to have opt-in flags separately for all plugins/user code; not? |
Hmmm that's a new idea, but I don't see a way to do that, for example everybody uses the same Besides the above, this implicit API switching going around in the background seems really hard, error prone, and make for hard to understand errors when they happen. 😬 |
They use the same |
I see your point, but even if we could get that to work reliably (I think it would be really hard to get it right), I believe this implicit API transformation would be just too confusing. Also because there are so many details involved, I'm sure there are corner cases where this would break down. One example: it is common for plugins to require users to define a fixture object (say an The boundary between user-code and plugins is not so clearly defined, I'm afraid. |
this pr is about exploring the dependency on
py.path.local
the ideal case would be to completely remove the need to use py.path and instead go for pathlib/pathlib2 only
the starting point however is support, and compatibility wrappers