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

661: update supported python versions #706

Merged
merged 1 commit into from
May 31, 2024

Conversation

lindsay-stevens
Copy link
Contributor

Closes #661
Closes #701

  • python 3.10, 3.11, 3.12 with 3.10 as the default
  • update ruff and lxml
  • ruff formatting changes for py3.10 are generally one of the following:
    • line at top of file after module docstring
    • typing:
      • Union[x, y] -> x | y
      • imports from typing to use either builtins or stdlib
    • replace simple string subs "%s" with f-strings
      • many still remain due to use of common templates etc
    • explicitly state new default strict=False for zip, map
    • parenthesis allowed in with to group contexts

Why is this the best possible solution? Were any other approaches considered?

Considered including 3.8 (EOL 2024-10) and 3.9 (EOL 2025-10) but that would have meant testing on 5 different major Python versions or excluding newer versions, being limited to the oldest version's syntax, and increasing the potential for code or library incompatibilities. Also, lately we have updated Python version support every 2 years (2020, 2022, 2024) so these would have gone out of support by 2026.

Considered supporting 3.12 only (in line with pyODK) but according to these PyPi stats it's adoption is about 5% as of 2024-05-04. Adoption of 3.10 to 3.12 inclusive is more like 40%. Using 3.10 as the default / lowest version allows for nice things like the newer typing syntax and structural pattern matching.

What are the regression risks?

The py3.10 typing syntax would throw an error for older Python versions. The f-strings replacements were fiddly and so could be off but I checked them over a few times and the tests pass.

Does this change require updates to documentation? If so, please file an issue here and include the link below.

Yes, the README is updated.

Before submitting this PR, please make sure you have:

  • included test cases for core behavior and edge cases in tests
  • run python -m unittest and verified all tests pass
  • run ruff format pyxform tests and ruff check pyxform tests to lint code
  • verified that any code or assets from external sources are properly credited in comments

- python 3.10, 3.11, 3.12 with 3.10 as the default
- update ruff and lxml
- formatting changes are generally one of the following:
  - line at top of file after module docstring
  - typing:
    - Union[x, y] -> x | y
    - imports from typing to use either builtins or stdlib
  - replace simple string subs "%s" with f-strings
    - many still remain due to use of common templates etc
  - explicitly state new default strict=False for zip, map
  - parenthesis allowed in with
@lognaturel
Copy link
Contributor

according to these PyPi stats it's adoption is about 5% as of 2024-05-04

😱 Should we consider expanding the range for pyodk? Maybe we only consider it if someone asks for it. I wonder whether that number is so low because most Python installations are just default ones that come with OS distributions.

| 1000 | 2.0054 | 2.1026 |
| 2000 | 4.0714 | 4.0926 |
| 3000 | 6.0266 | 6.2476 |
| 500 | 3.0420 | 3.0427 |
Copy link
Contributor

Choose a reason for hiding this comment

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

Fascinating to see these numbers and the relationship between them change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep I've added #708 for follow up

Copy link
Contributor

@lognaturel lognaturel left a comment

Choose a reason for hiding this comment

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

Hurray! 🎉

@lognaturel lognaturel merged commit 1599d1f into XLSForm:master May 31, 2024
10 checks passed
@lindsay-stevens lindsay-stevens deleted the pyxform-661 branch June 3, 2024 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants