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

Reduce Minimum Required Python Version to 3.10 #23

Merged
merged 1 commit into from
May 22, 2024
Merged

Conversation

GrammAcc
Copy link
Owner

I have removed use of the runtime features that were added in 3.11 or later.

We're still using typing features from later versions which is fine since type annotations aren't evaluated at runtime and we can run the type checker in a newer version with hatch.

Breaking changes:

  1. Remove use of enum.StrEnum for linearmoney.data.FormatType.
  • StrEnum was added in 3.11, so I have changed FormatType to be a regular enum.Enum with a custom __str__ that returns the value of the enum member instead of the name and value together.
  • This introduces an internal change to the way that we lookup the format for locale data. Passing a string literal such as "standard" to the linearmoney.data.locale function's nformat argument will still work in the current implementation, but this is now an implementation detail and not an officially supported usage of the api. This can change at any time, so callers that are providing a format type to the locale function should use the actual members of the linearmoney.data.FormatType enum instead of passing in strings directly.
  • The type checker will error if a string literal is provided, even if it works at runtime. I'm not sure if this would happen in the previous implementation since I never tried it, but StrEnums are supposed to behave like strings, so it's probably up to the specific type checker whether that was considered an error. It's always an error now, so this should make it easier to spot potentially flaky uses of string literals in locale definitions.

I have removed use of the runtime features that were added in 3.11 or
later.

We're still using typing features from later versions which is fine
since type annotations aren't evaluated at runtime and we can run the
type checker in a newer version with hatch.

Breaking changes:
1. Remove use of `enum.StrEnum` for `linearmoney.data.FormatType`.
  - `StrEnum` was added in 3.11, so I have changed `FormatType` to be a
    regular `enum.Enum` with a custom `__str__` that returns the value
    of the enum member instead of the name and value together.
  - This introduces an internal change to the way that we lookup the
    format for locale data. Passing a string literal such as
    `"standard"` to the `linearmoney.data.locale` function's `nformat`
    argument will still work in the current implementation, but this is
    now an implementation detail and not an officially supported
    usage of the api. This can change at any time, so callers that are
    providing a format type to the `locale` function should use the
    actual members of the `linearmoney.data.FormatType` enum instead of
    passing in strings directly.
  - The type checker will error if a string literal is provided, even if
    it works at runtime. I'm not sure if this would happen in the
    previous implementation since I never tried it, but StrEnums are
    supposed to behave like strings, so it's probably up to the specific
    type checker whether that was considered an error. It's always an
    error now, so this should make it easier to spot potentially flaky
    uses of string literals in locale definitions.
@GrammAcc GrammAcc added the enhancement New feature or request label May 22, 2024
@GrammAcc GrammAcc merged commit 076beac into dev May 22, 2024
2 checks passed
@GrammAcc GrammAcc deleted the support-py310 branch May 22, 2024 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant