Skip to content

Commit df0ce68

Browse files
authored
Enable UP007 in pyupgrade and update type hints (#4937)
1 parent 16b0734 commit df0ce68

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ ignore = [
208208
"RET506", # Unnecessary `elif`
209209
"B018", # Found useless expression
210210
"RUF002", # Docstring contains ambiguous
211-
"UP007", # For pyupgrade
212211
]
213212

214213
[tool.ruff.lint.per-file-ignores]

src/pybamm/expression_tree/concatenations.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
from __future__ import annotations
2+
13
#
24
# Concatenation classes
35
#
46
from __future__ import annotations
57
import copy
68
from collections import defaultdict
7-
from typing import Optional
89

910
import numpy as np
1011
import numpy.typing as npt
@@ -470,7 +471,7 @@ def _concatenation_new_copy(self, children, perform_simplifications=True):
470471
class ConcatenationVariable(Concatenation):
471472
"""A Variable representing a concatenation of variables."""
472473

473-
def __init__(self, *children, name: Optional[str] = None):
474+
def __init__(self, *children, name: str | None = None):
474475
if name is None:
475476
# Name is the intersection of the children names (should usually make sense
476477
# if the children have been named consistently)
@@ -526,7 +527,7 @@ def intersect(s1: str, s2: str):
526527
return intersect.lstrip().rstrip()
527528

528529

529-
def simplified_concatenation(*children, name: Optional[str] = None):
530+
def simplified_concatenation(*children, name: str | None = None):
530531
"""Perform simplifications on a concatenation."""
531532
# remove children that are None
532533
children = list(filter(lambda x: x is not None, children))
@@ -556,7 +557,7 @@ def simplified_concatenation(*children, name: Optional[str] = None):
556557
return concat
557558

558559

559-
def concatenation(*children, name: Optional[str] = None):
560+
def concatenation(*children, name: str | None = None):
560561
"""Helper function to create concatenations."""
561562
# TODO: add option to turn off simplifications
562563
return simplified_concatenation(*children, name=name)

0 commit comments

Comments
 (0)