Skip to content

Conversation

@miettal
Copy link

@miettal miettal commented Jan 11, 2026

Summary

Suppress DeprecationWarning for PurePath.as_uri() in Python 3.14+.

Problem

Python 3.14 deprecated PurePath.as_uri() (removal scheduled for 3.19). This causes warnings when LocationPath.as_uri() is called.

Solution

Add warnings.catch_warnings() to suppress the deprecation warning in LocationPath.as_uri(). The custom implementation doesn't call the parent method and provides necessary functionality for URI conversion.

Changes

  • Import warnings module
  • Wrap implementation with warning suppression
  • Add explanatory comment

🤖 Generated with Claude Code

Co-Authored-By: Claude [email protected]

Suppress the DeprecationWarning for PurePath.as_uri() in LocationPath.as_uri()
method. The warning appears in Python 3.14+ as PurePath.as_uri() is scheduled
for removal in Python 3.19.

The LocationPath class provides a custom implementation that doesn't call the
parent method and is necessary for proper URI conversion of location paths.
The deprecation warning is safely suppressed as this is an intentional override
with a valid use case.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@brunato
Copy link
Member

brunato commented Jan 12, 2026

The current implementation shouldn't use the PurePath.as_uri(), maybe it happens with the usage of another API. Do you have an evidence of that with a specific case that generates the warning? (better open an issue in this case)

thank you

@miettal
Copy link
Author

miettal commented Jan 13, 2026

Sorry I only have pytest ignore setting now. This is a pattern of the warning.

  "ignore:^pathlib\\.PurePath\\.as_uri\\(\\) is deprecated and scheduled for removal in Python 3\\.19\\..*:DeprecationWarning",

@brunato
Copy link
Member

brunato commented Jan 13, 2026

Well, but with latest versions of xmlschema and elementpath the tests run doesn't produce any warning to me, also with pytest. Can you report which test/tests produce a warning?
thanks

@brunato brunato closed this Jan 20, 2026
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

Successfully merging this pull request may close these issues.

2 participants