-
Notifications
You must be signed in to change notification settings - Fork 29
Remove python 2 compatibility, add type hints #80
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
Changes from all commits
d3fc935
82b9cec
dea8ca3
195aac0
2a7027e
050f2e5
35c6284
388a6da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # Static type checking | ||
|
|
||
| name: Static type checking | ||
|
|
||
| on: | ||
| push: | ||
| branches: ["master"] | ||
| pull_request: | ||
| branches: ["master"] | ||
|
|
||
| jobs: | ||
| test: | ||
| name: Static type checking | ||
| runs-on: ubuntu-latest | ||
| container: python:3.13-alpine3.21 | ||
|
|
||
| steps: | ||
| - name: Install Alpine Dependencies | ||
| run: apk add git | ||
| - name: Display Python version | ||
| run: python -c "import sys; print(sys.version)" | ||
| - name: Display Git version | ||
| run: git --version | ||
|
|
||
| - uses: actions/checkout@v4 | ||
| with: | ||
| submodules: recursive | ||
|
|
||
| - name: Install Dependencies | ||
| run: pip install -e ".[dev]" | ||
| - name: Run mypy | ||
| run: mypy --strict editorconfig | ||
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -6,23 +6,25 @@ | |||||
| """ | ||||||
|
|
||||||
| import re | ||||||
| from typing import Optional | ||||||
|
|
||||||
|
|
||||||
| __all__ = ['join_version', 'split_version'] | ||||||
|
|
||||||
|
|
||||||
| _version_re = re.compile(r'^(\d+)\.(\d+)\.(\d+)(\..*)?$', re.VERBOSE) | ||||||
|
|
||||||
| VersionTuple = tuple[int, int, int, str] | ||||||
|
|
||||||
| def join_version(version_tuple): | ||||||
| def join_version(version_tuple: VersionTuple) -> str: | ||||||
| """Return a string representation of version from given VERSION tuple""" | ||||||
| version = "%s.%s.%s" % version_tuple[:3] | ||||||
| if version_tuple[3] != "final": | ||||||
| version += "-%s" % version_tuple[3] | ||||||
| return version | ||||||
|
|
||||||
|
|
||||||
| def split_version(version): | ||||||
| def split_version(version: str) -> Optional[VersionTuple]: | ||||||
| """Return VERSION tuple for given string representation of version""" | ||||||
| match = _version_re.search(version) | ||||||
| if not match: | ||||||
|
|
@@ -31,5 +33,4 @@ def split_version(version): | |||||
| split_version = list(match.groups()) | ||||||
| if split_version[3] is None: | ||||||
| split_version[3] = "final" | ||||||
| split_version = list(map(int, split_version[:3])) + split_version[3:] | ||||||
| return tuple(split_version) | ||||||
| return (int(split_version[0]), int(split_version[1]), int(split_version[2]), split_version[3]) | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the old code looks fine.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mypy doesn't understand the old code, that's why I changed it. (Also, I think it's much more readable after the change, but that's just my opinion.) |
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we want to use alpine3.21 here, renovate bots won't bump 3.21. Maybe just alpine or use
setup-python?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That part was copied verbatim from the other workflow (
runtime.yml).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy to change it of course, just wanted to point out that sticking to a specific alpine version was not my own decision.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, it's fine then. We can tackle it separately.