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

Add support for Py 3.13 #221

Merged
merged 2 commits into from
Aug 3, 2024
Merged

Add support for Py 3.13 #221

merged 2 commits into from
Aug 3, 2024

Conversation

facelessuser
Copy link
Owner

  • Support Py 3.13
  • Remove deprecated raw_escape
  • Remove casting which incurs a performance cost for little gain. Once that cannot easily be resolved, just ignore the mypy error.
  • Update formatted strings to f-string (where possible)

- Support Py 3.13
- Remove deprecated `raw_escape`
- Remove casting which incurs a performance cost for little gain.
  Once that cannot easily be resolved, just ignore the mypy error.
- Update formatted strings to f-string (where possible)
@gir-bot gir-bot added S: needs-review Needs to be reviewed and/or approved. C: docs Related to documentation. C: glob Glob library. C: infrastructure Related to project infrastructure. C: pathlib Pathlib library. C: pattern-parser Related to pattern parsing. C: source Related to source code. C: tests Related to testing. labels Aug 3, 2024
@facelessuser
Copy link
Owner Author

The niche, deprecated function that we are removing can replicated via the code below. I want to document it here in case there are questions about it.

def raw_escape(pattern: AnyStr, unix: bool | None = None, raw_chars: bool = True) -> AnyStr:
    """
    Escape a raw string as if it was a normal string.

    pattern: pattern to escape.
    unix: True or False to force Unix or Windows mode, None to allow detection based on system.
    raw_chars: Process raw string and convert Python escaped Unicode or ASCII characters.
    """

    import codecs

    if isinstance(pattern, bytes):
        pattern = pattern.replace(b'\\\\', b'\\') if not raw_chars else codecs.escape_decode(pattern)[0]
    else:
        pattern = pattern.replace('\\\\', '\\') if not raw_chars else codecs.unicode_escape_decode(pattern)[0]

    return escape(pattern, unix=unix)

@facelessuser
Copy link
Owner Author

@gir-bot lgtm

@gir-bot gir-bot added S: approved The pull request is ready to be merged. and removed S: needs-review Needs to be reviewed and/or approved. labels Aug 3, 2024
@facelessuser facelessuser merged commit 2939d2a into main Aug 3, 2024
17 checks passed
@facelessuser facelessuser deleted the chore/py313 branch August 3, 2024 03:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: docs Related to documentation. C: glob Glob library. C: infrastructure Related to project infrastructure. C: pathlib Pathlib library. C: pattern-parser Related to pattern parsing. C: source Related to source code. C: tests Related to testing. S: approved The pull request is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants