Skip to content
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

Circular deprecation warning w.r.t. datafile/filename/path #61

Open
hugobuddel opened this issue Nov 17, 2024 · 2 comments
Open

Circular deprecation warning w.r.t. datafile/filename/path #61

hugobuddel opened this issue Nov 17, 2024 · 2 comments
Assignees

Comments

@hugobuddel
Copy link
Contributor

hugobuddel commented Nov 17, 2024

Running the speXtra tests lead to a large number of warnings:

PendingDeprecationWarning: The 'name plus file extension' property will be moved to .filename in the next minor pre-release, making .datafile deprecated.

However, there seems no clear way to remedy the warning, as the datafile property says to use filename:

    @property
    def datafile(self):
        """Name and extension of the file."""
        warnings.warn("The 'name plus file extension' property will be moved "
                      "to .filename in the next minor pre-release, making "
                      ".datafile deprecated.",
                      PendingDeprecationWarning, 2)
        return self.basename + self.library.file_extension

but the filename property itself is already deprecated and says to use path:

    @property
    def filename(self):
        """Deprecated feature."""
        warnings.warn("The .filename property is deprecated and will refer to "
                      "the full name incl. file extension in future versions. "
                      "For the absolute file path, please use .path instead!",
                      DeprecationWarning, 2)

and path in turn accesses datafile, completing the circle:

    @property
    def path(self) -> Path:
        """Path to the cached file."""
        ...
        return spextra_database.fetch(f"{self.library.path}/{self.datafile}")

I'm trying to add

filterwarnings = [
    "error",
]

to pyproject.toml, and fix some of the deprecation warnings that are raised, but I cannot figure out how to get rid of our own deprecation warning.

The deprecations seem to have been introduced in #10, but I haven't checked whether they were there before that refactoring.

@teutoburg
Copy link
Contributor

They were not here before, I put those in. Mostly to see if they pop up anywhere else (i.e. if those properties are called from outside spextra itself, e.g. by some code in ScopeSim). I had to do some major refactoring with these attributes and properties (in #10) because they were inconsistent before, but didn't want to completely break everything existing. My plan was to eventually remove these things, or rather make them do what it says in those warnings, but I forgot to do that in last 10-ish months...

@hugobuddel
Copy link
Contributor Author

I don't think we had to ignore the warning in the other projects, so maybe it is not called anywhere. But apparently we don't yet run all projects with warning=error, so not sure.

I don't actually recall why I decided to try adding warning=error to speXtra, must have had to do with AstarVienna/ScopeSim_Data#20 .

This doesn't really matter, but it was not directly obvious what the plan actually is. Not that I put too much effort in it, I gave up once I noticed the (current) circular deprecation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants