Skip to content

Conversation

@mdevolde
Copy link
Collaborator

feat: added a way to mark funcs as deprecated (compatible py 3.9-3.14)

Why the pull request was made

In order to introduce new interfaces without bumping the MAJOR version of the library, there was a need for a way to mark functions as deprecated, compatible from Python version 3.9 to version 3.14.

A solution would be to use the deprecated decorator from typing_extensions lib, but doesn't wan't to add a dependancy.

Summary of changes

  • Added a private module containing :
    • python 3.9 - 3.12 : the new deprecated decorator (destinated for internal use).
    • python 3.13 - 1.14 : the deprecated decorator from warnings lib.
  • Added an ignored rule in pyproject.toml (because the written decorator is typed, and the warnings one isn't, so using a type: ignore will trigger a mypy warning with the first one, and not with the second one).

Screenshots (if appropriate):

Not appropriate.

How has this been tested?

Tested by applying both on lib funcs.

Resources

https://docs.python.org/3/library/warnings.html#warnings.deprecated

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update (changes to documentation only)
  • Refactor / code style update (non-breaking change that improves code structure or readability)
  • Tests / CI improvement (adding or updating tests or CI configuration only)
  • Other (please describe):

Checklist

  • Followed the project's contributing guidelines.
  • Updated any relevant tests.
  • Updated any relevant documentation.
  • Added comments to your code where necessary.
  • Formatted your code, run the linters, checked types and tests.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a deprecated decorator compatible with Python 3.9-3.14 to enable marking functions as deprecated without adding external dependencies. The implementation uses the standard library warnings.deprecated for Python 3.13+ and provides a custom fallback for earlier versions.

Changes:

  • Added language_tool_python/_deprecated.py module with conditional import logic for the deprecated decorator
  • Updated mypy configuration in pyproject.toml to ignore unused type:ignore comments

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
language_tool_python/_deprecated.py New module providing deprecated decorator with fallback implementation for Python <3.13
pyproject.toml Added "unused-ignore" to mypy's disable_error_code list for cross-version type annotation compatibility

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mdevolde mdevolde merged commit 35b89a0 into jxmorris12:master Jan 12, 2026
8 checks passed
@mdevolde mdevolde deleted the deprecated branch January 12, 2026 22:29
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.

1 participant