From 6ddb545491d33303e9f83cde1ffd50b39735b45c Mon Sep 17 00:00:00 2001 From: Alexander Hess Date: Wed, 16 Oct 2024 11:39:52 +0200 Subject: [PATCH] Remove unnecessary `Optional` The type hints `object` and `Optional[object]` both allow the default value `None`. Also, this commit gets rid of ruff's "FA100" error for the two changed lines. --- src/lalib/elements/galois.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/lalib/elements/galois.py b/src/lalib/elements/galois.py index 7ea450d..42aebab 100644 --- a/src/lalib/elements/galois.py +++ b/src/lalib/elements/galois.py @@ -32,9 +32,7 @@ import abc import functools import math import numbers - -# When giving up support for Python 3.9, we can get rid of `Optional` -from typing import Callable, ClassVar, Literal, Optional +from typing import Callable, ClassVar, Literal try: @@ -502,7 +500,7 @@ class GF2Element(metaclass=GF2Meta): """ return self._compute(other, lambda s, o: o % s) - def __pow__(self, other: object, _modulo: Optional[object] = None) -> Self: + def __pow__(self, other: object, _modulo: object = None) -> Self: """Exponentiation: `self ** other`. Powers of `gf2` values are like powers of `int`s. @@ -520,7 +518,7 @@ class GF2Element(metaclass=GF2Meta): """ return self._compute(other, lambda s, o: s**o) - def __rpow__(self, other: object, _modulo: Optional[object] = None) -> Self: + def __rpow__(self, other: object, _modulo: object = None) -> Self: """(Reflected) Exponentiation: `other ** self`. See docstring for `.__pow__()`.