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

Drop support for Python 3.9, drop Optional and Union from type hints #908

Merged
merged 4 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions docs/source/examples/gen_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from collections import defaultdict
from collections.abc import Iterable
from pathlib import Path
from typing import Union

from tqdm import tqdm

Expand All @@ -24,7 +23,7 @@
logger = logging.getLogger()


def _bool_to_icon(x: Union[bool, Iterable]) -> str:
def _bool_to_icon(x: bool | Iterable) -> str:
if x:
return "✅"
else:
Expand Down
25 changes: 11 additions & 14 deletions docs/source/settings/gen_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,16 @@
# We cannot use ast for this because it doesn't preserve comments. We could use
# something like redbaron, but our code is hopefully simple enough!
assign_re = re.compile(
# Line starts with annotation syntax (name captured by the first group).
r"^(\w+): "
# Then the annotation can be ...
"("
# ... a standard assignment ...
".+ = .+"
# ... or ...
"|"
# ... the start of a multiline type annotation like "a: Union["
r"(Union|Optional|Literal)\["
# To the end of the line.
")$",
"^" # The line starts, then is followed by
r"(\w+): " # annotation syntax (name captured by the first group),
"(?:" # then the rest of the line can be (in a non-capturing group):
".+ = .+" # 1. a standard assignment
"|" # 2. or
r"Literal\[" # 3. the start of a multiline type annotation like "a: Literal["
"|" # 4. or
r"\(" # 5. the start of a multiline 3.9+ type annotation like "a: ("
")" # Then the end of our group
"$", # and immediately the end of the line.
Comment on lines +102 to +111
Copy link
Member

Choose a reason for hiding this comment

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

@hoechenberger this should work, make more sense?

re.MULTILINE,
)

Expand Down Expand Up @@ -186,8 +184,7 @@ def main():
match = assign_re.match(line)
if match is not None:
have_params = True
name, typ, desc = match.groups()
current_lines.append(f"{prefix}{name}")
current_lines.append(f"{prefix}{match.groups()[0]}")
continue


Expand Down
8 changes: 6 additions & 2 deletions docs/source/v1.9.md.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@

### :new: New features & enhancements

- Added number of subject to sub-average report (#902 by @SophieHerbst)
- Added number of subject to `sub-average` report (#902 by @SophieHerbst)
- The type annotations in the default configuration file are now easier to read: We
replaced `Union[X, Y]` with `X | Y` and `Optional[X]` with `X | None`. (#908 by @hoechenberger)

[//]: # (- Whatever (#000 by @whoever))

[//]: # (### :warning: Behavior changes)

[//]: # (- Whatever (#000 by @whoever))

[//]: # (### :package: Requirements)
### :package: Requirements

- We dropped support for Python 3.9. You now need Python 3.10 or newer.

[//]: # (- Whatever (#000 by @whoever))

Expand Down
Loading