Skip to content

Commit

Permalink
Drop support for Python 3.9, drop Optional and Union from type hi…
Browse files Browse the repository at this point in the history
…nts (mne-tools#908)

Co-authored-by: Eric Larson <[email protected]>
  • Loading branch information
hoechenberger and larsoner authored Mar 28, 2024
1 parent ed5939a commit 96251a8
Show file tree
Hide file tree
Showing 41 changed files with 356 additions and 381 deletions.
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.
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

0 comments on commit 96251a8

Please sign in to comment.