-
Notifications
You must be signed in to change notification settings - Fork 1.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
File: Add full_path() method #12408
File: Add full_path() method #12408
Conversation
Awesome. I'm afk most of the day today, but will try this tonight or tomorrow. |
d092a45
to
fd8fa45
Compare
mypy failing |
Untrue. The change in str.format() is totally irrelevant since they don't even do the same thing, "not even mostly".
Also untrue. Other objects do not have statically known-at-authorship-time names. In particular, executables and libraries can have absolutely any name at all because meson chooses file extensions itself based on the platform (and there's no actual way to tell what that is going to be). To the extent that str.format was ever useful or accomplished any task whatsoever, the fs module's fs.name() function achieves precisely the same goal. More generally it sort of feels to me like the fs module is a more elegant approach to the problem domain. I've wondered a time or two whether we should deprecate full_path and replace it with fs module APIs, actually. |
@eli-schwartz I will post a PR for adding support to various types to the fs module. Maybe we can land it for 1.3 if I am quick enough. |
Hi,
How is it not relevant that you invented a new kind of deprecations - which do not respect minimum_version and warn at every callsite) - preventing meson users from using I really don't understand why the use of str.format() of other types is worth going this extra mile just to break peoples use of meson. "Project uses feature that was always broken" - it just wasn't, it obviously worked for some purposes. It was ugly, it perhaps had downsides. But it wasn't "always broken".
From what I can tell
Maybe - but I think it'd need a new function to be comparable. Needing to replace Greetings, Andres |
@xclaesse Tried the PR out, worked without a problem here! |
Adding a new deprecation for something that "never worked reliably or correctly" is a matter of warning people that we cannot and will not commit to it working, nor ever did. It does not imply that there's a replacement. There doesn't have to be a replacement. There is nothing wrong with a replacement existing, but it isn't inherent to the nature of issuing a deprecation warning if we genuinely believe that something as it is today is broken. Adding a replacement is a separate concern -- it is adding new functionality that, frankly, never existed before. We've deprecated many things other than files() objects here -- lots of things that don't have replacements, and aren't being proposed for replacement here, but which actually used to dump really badly formatted python repr()s. Of course there is pressure to find another solution. But remember that previously existing build files are not supposed to break as a result of this change. Issuing a warning doesn't cause builds to fail. I believe this is a very important distinction. Mostly, what I'm trying to point out is that this proposed feature should be considered on its own merit (and I agree it has independent merit).
The fs module documentation is module documentation -- this means that it doesn't have as nice function signature docs as the non-module functions, as those never got migrated. However, it is documented (using prose):
I should note that fs.as_posix() doesn't support files objects either, and it seems to be ambiguous whether it "can do something useful with them" but isn't explicitly called out here as not supporting it.
Yes, sorry for not making myself clear -- I actually did mean I've thought about adding new fs module APIs for this, not asking people to combine fs.name + fs.parent |
Are you thinking like an fs.path() function Eli? |
fd8fa45
to
731e8cd
Compare
I'm not sure to understand in which world it makes more sense to use a fs module function rather than a method on the object itself. Especially since we already have full_path() on other object types (build target, custom target, programs). |
I agree having it as a method is cleaner. Because otherwise if you just want to get the path you potentially have to do fs = import('fs')
something(fs.path(other)) as opposed to the one-liner something(other.full_path()) |
Test failure is relevant:
|
That should probably be:
|
I think the problem in the test case is the |
This is needed now that str.format() is not allowing it any more. It is also more consistent with other objects that have that method as well, such as build targets. Fixes: mesonbuild#12406
731e8cd
to
22a6a43
Compare
This is needed now that str.format() is not allowing it any more. It is also more consistent with other objects that have that method as well, such as build targets.
Fixes: #12406