Skip to content

Commit b001906

Browse files
committed
Run pyupgrade
ruff check --select=UP,F401 --unsafe-fixes docs magicbot robotpy_ext --fix
1 parent 1678762 commit b001906

File tree

10 files changed

+25
-26
lines changed

10 files changed

+25
-26
lines changed

docs/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python3
2-
# -*- coding: utf-8 -*-
32

43
import sys
54
import os

magicbot/inject.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import logging
2-
from typing import Any, Dict, Optional
2+
from typing import Any, Optional
33

44
logger = logging.getLogger(__name__)
55

@@ -9,8 +9,8 @@ class MagicInjectError(ValueError):
99

1010

1111
def get_injection_requests(
12-
type_hints: Dict[str, type], cname: str, component: Optional[Any] = None
13-
) -> Dict[str, type]:
12+
type_hints: dict[str, type], cname: str, component: Optional[Any] = None
13+
) -> dict[str, type]:
1414
"""
1515
Given a dict of type hints, filter it to the requested injection types.
1616
@@ -52,8 +52,8 @@ def get_injection_requests(
5252

5353

5454
def find_injections(
55-
requests: Dict[str, type], injectables: Dict[str, Any], cname: str
56-
) -> Dict[str, Any]:
55+
requests: dict[str, type], injectables: dict[str, Any], cname: str
56+
) -> dict[str, Any]:
5757
"""
5858
Get a dict of the variables to inject into a given component.
5959

magicbot/magic_reset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Dict, Generic, TypeVar
1+
from typing import Any, Generic, TypeVar
22

33
V = TypeVar("V")
44

@@ -36,7 +36,7 @@ def __init__(self, default: V) -> None:
3636
self.default = default
3737

3838

39-
def collect_resets(cls: type) -> Dict[str, Any]:
39+
def collect_resets(cls: type) -> dict[str, Any]:
4040
"""
4141
Get all the ``will_reset_to`` variables and their values from a class.
4242

magicbot/magic_tunable.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
import inspect
44
import typing
55
import warnings
6-
from typing import Callable, Generic, Optional, Sequence, TypeVar, Union, overload
6+
from typing import Callable, Generic, Optional, TypeVar, Union, overload
7+
from collections.abc import Sequence
78

89
import ntcore
910
from ntcore import NetworkTableInstance

magicbot/magicrobot.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import types
66
import typing
77

8-
from typing import Any, Callable, Dict, List, Tuple
8+
from typing import Any, Callable
99

1010
import hal
1111
import wpilib
@@ -72,9 +72,9 @@ def __init__(self) -> None:
7272

7373
self.__last_error_report = -10
7474

75-
self._components: List[Tuple[str, Any]] = []
76-
self._feedbacks: List[Tuple[Callable[[], Any], Callable[[Any], Any]]] = []
77-
self._reset_components: List[Tuple[Dict[str, Any], Any]] = []
75+
self._components: list[tuple[str, Any]] = []
76+
self._feedbacks: list[tuple[Callable[[], Any], Callable[[Any], Any]]] = []
77+
self._reset_components: list[tuple[dict[str, Any], Any]] = []
7878

7979
self.__done = False
8080

@@ -125,7 +125,7 @@ def robotInit(self) -> None:
125125

126126
self.watchdog = SimpleWatchdog(self.control_loop_wait_time)
127127

128-
self.__periodics: List[Tuple[Callable[[], None], str]] = [
128+
self.__periodics: list[tuple[Callable[[], None], str]] = [
129129
(self.robotPeriodic, "robotPeriodic()"),
130130
]
131131

@@ -397,7 +397,7 @@ def autonomous(self) -> None:
397397
except:
398398
self.onException(forceReport=True)
399399

400-
auto_functions: Tuple[Callable[[], None], ...] = (self._enabled_periodic,)
400+
auto_functions: tuple[Callable[[], None], ...] = (self._enabled_periodic,)
401401

402402
if self.use_teleop_in_autonomous:
403403
auto_functions = (self.teleopPeriodic,) + auto_functions
@@ -649,7 +649,7 @@ def _create_components(self) -> None:
649649

650650
self._components = components
651651

652-
def _collect_injectables(self) -> Dict[str, Any]:
652+
def _collect_injectables(self) -> dict[str, Any]:
653653
injectables = {}
654654
cls = type(self)
655655

@@ -672,7 +672,7 @@ def _collect_injectables(self) -> Dict[str, Any]:
672672

673673
return injectables
674674

675-
def _create_component(self, name: str, ctyp: type, injectables: Dict[str, Any]):
675+
def _create_component(self, name: str, ctyp: type, injectables: dict[str, Any]):
676676
type_hints = typing.get_type_hints(ctyp.__init__)
677677
NoneType = type(None)
678678
init_return_type = type_hints.pop("return", NoneType)
@@ -699,7 +699,7 @@ def _create_component(self, name: str, ctyp: type, injectables: Dict[str, Any]):
699699

700700
return component
701701

702-
def _setup_vars(self, cname: str, component, injectables: Dict[str, Any]) -> None:
702+
def _setup_vars(self, cname: str, component, injectables: dict[str, Any]) -> None:
703703
self.logger.debug("Injecting magic variables into %s", cname)
704704

705705
type_hints = typing.get_type_hints(type(component))

magicbot/state_machine.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
Any,
55
Callable,
66
ClassVar,
7-
Dict,
87
NoReturn,
98
Optional,
10-
Sequence,
119
Union,
1210
overload,
1311
)
12+
from collections.abc import Sequence
1413

1514
import wpilib
1615

@@ -260,7 +259,7 @@ def default_state(f: StateMethod) -> _State:
260259
return _State(f, first=False, must_finish=True, is_default=True)
261260

262261

263-
def _get_class_members(cls: type) -> Dict[str, Any]:
262+
def _get_class_members(cls: type) -> dict[str, Any]:
264263
"""Get the members of the given class in definition order, bases first."""
265264
d = {}
266265
for cls in reversed(cls.__mro__):

robotpy_ext/autonomous/selector.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
import logging
44
import os
55
from glob import glob
6-
from typing import Callable, Sequence, Union
6+
from typing import Callable, Union
7+
from collections.abc import Sequence
78

89
import hal
910
import wpilib

robotpy_ext/common_drivers/driver_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class DriverBase(object):
1+
class DriverBase:
22
"""
33
This should be the base class for all drivers in the cdl,
44
currently all it does is spit out a warning message if the driver has not been verified.

robotpy_ext/common_drivers/units.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class Unit(object):
1+
class Unit:
22
"""The class for all of the units here"""
33

44
def __init__(self, base_unit, base_to_unit, unit_to_base):

robotpy_ext/misc/simple_watchdog.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import wpilib
22
import logging
3-
from typing import List, Tuple
43

54
logger = logging.getLogger("simple_watchdog")
65

@@ -38,7 +37,7 @@ def __init__(self, timeout: float):
3837
self._expirationTime = 0 # us
3938
self._lastTimeoutPrintTime = 0 # us
4039
self._lastEpochsPrintTime = 0 # us
41-
self._epochs: List[Tuple[str, int]] = []
40+
self._epochs: list[tuple[str, int]] = []
4241

4342
def getTime(self) -> float:
4443
"""Returns the time in seconds since the watchdog was last fed."""

0 commit comments

Comments
 (0)