Skip to content

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

@hugobuddel

Description

@hugobuddel

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions