From f71ac76af0c43309585a11d20b18edc516e849ca Mon Sep 17 00:00:00 2001 From: Alexandru Fikl Date: Fri, 26 Sep 2025 10:55:47 +0300 Subject: [PATCH 1/4] chore: drop pylint --- .github/workflows/ci.yml | 21 --------------------- .gitlab-ci.yml | 11 ----------- .pylintrc-local.yml | 3 --- pyproject.toml | 1 + 4 files changed, 1 insertion(+), 35 deletions(-) delete mode 100644 .pylintrc-local.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 58f8b959..19c365d3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,27 +34,6 @@ jobs: pip install ruff ruff check - pylint: - name: Pylint - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v5 - - - uses: actions/setup-python@v6 - with: - python-version: '3.x' - - name: "Main Script" - run: | - EXTRA_INSTALL="numpy sympy scipy pexpect" - curl -L -O https://tiker.net/ci-support-v0 - . ./ci-support-v0 - build_py_project_in_venv - - # https://github.com/inducer/pymbolic/pull/66#issuecomment-950371315 - pip install symengine || true - - run_pylint pymbolic test/test_*.py - basedpyright: runs-on: ubuntu-latest diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 543be432..e6f68b03 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -29,17 +29,6 @@ Python 3 Conda: reports: junit: test/pytest.xml -Pylint: - script: - - EXTRA_INSTALL="numpy sympy symengine scipy pexpect" - - PY_EXE=python3 - - curl -L -O https://gitlab.tiker.net/inducer/ci-support/raw/main/prepare-and-run-pylint.sh - - ". ./prepare-and-run-pylint.sh pymbolic test/test_*.py" - tags: - - python3 - except: - - tags - Documentation: script: - EXTRA_INSTALL="numpy sympy" diff --git a/.pylintrc-local.yml b/.pylintrc-local.yml deleted file mode 100644 index 7b1ba436..00000000 --- a/.pylintrc-local.yml +++ /dev/null @@ -1,3 +0,0 @@ -- arg: ignored-modules - val: - - symengine diff --git a/pyproject.toml b/pyproject.toml index f0980c7a..a39d2ee2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,6 +40,7 @@ numpy = [ "numpy>=1.6", ] test = [ + "basedpyright", "pytest", "ruff", # only needed for type checking From 1bd163f618f5bb84b0b8e615e6326447de75151e Mon Sep 17 00:00:00 2001 From: Alexandru Fikl Date: Fri, 26 Sep 2025 10:57:21 +0300 Subject: [PATCH 2/4] chore: remove unused pylint comments --- pymbolic/algorithm.py | 2 +- pymbolic/interop/matchpy/tofrom.py | 2 -- pymbolic/interop/symengine.py | 4 ++-- pymbolic/interop/sympy.py | 2 +- pymbolic/mapper/constant_converter.py | 4 ++-- pymbolic/mapper/evaluator.py | 2 -- pymbolic/parser.py | 4 ++-- pymbolic/primitives.py | 2 +- test/test_pymbolic.py | 2 +- 9 files changed, 10 insertions(+), 14 deletions(-) diff --git a/pymbolic/algorithm.py b/pymbolic/algorithm.py index e07ed9ad..7a175d1e 100644 --- a/pymbolic/algorithm.py +++ b/pymbolic/algorithm.py @@ -308,7 +308,7 @@ def csr_matrix_multiply(S, x): # noqa result = numpy.empty_like(x) for i in range(h): - result[i] = sum(S.data[idx]*x[S.indices[idx]] # pylint:disable=unsupported-assignment-operation + result[i] = sum(S.data[idx]*x[S.indices[idx]] for idx in range(S.indptr[i], S.indptr[i+1])) return result diff --git a/pymbolic/interop/matchpy/tofrom.py b/pymbolic/interop/matchpy/tofrom.py index 79db5591..845cf39c 100644 --- a/pymbolic/interop/matchpy/tofrom.py +++ b/pymbolic/interop/matchpy/tofrom.py @@ -120,7 +120,6 @@ def map_logical_and(self, expr: p.LogicalAnd) -> m.LogicalAnd: @override def map_comparison(self, expr: p.Comparison) -> m.Comparison: - # pylint: disable=too-many-function-args return m.Comparison(self.rec(expr.left), m.ComparisonOp(expr.operator), self.rec(expr.right), @@ -128,7 +127,6 @@ def map_comparison(self, expr: p.Comparison) -> m.Comparison: @override def map_if(self, expr: p.If) -> m.If: - # pylint: disable=too-many-function-args return m.If(self.rec(expr.condition), self.rec(expr.then), self.rec(expr.else_)) diff --git a/pymbolic/interop/symengine.py b/pymbolic/interop/symengine.py index 31d06019..4992e8bc 100644 --- a/pymbolic/interop/symengine.py +++ b/pymbolic/interop/symengine.py @@ -84,9 +84,9 @@ def function_name(self, expr): return type(expr).__name__ def not_supported(self, expr): - from symengine.lib.symengine_wrapper import PyFunction # pylint: disable=E0611 + from symengine.lib.symengine_wrapper import PyFunction if isinstance(expr, PyFunction) and \ - self.function_name(expr) == "CSE": # pylint: disable=E0611 + self.function_name(expr) == "CSE": sympy_expr = expr._sympy_() return prim.CommonSubexpression( self.rec(expr.args[0]), sympy_expr.prefix, sympy_expr.scope) diff --git a/pymbolic/interop/sympy.py b/pymbolic/interop/sympy.py index 8da06e30..db866bc4 100644 --- a/pymbolic/interop/sympy.py +++ b/pymbolic/interop/sympy.py @@ -59,7 +59,7 @@ def function_name(self, expr): # only called for Py2 def map_long(self, expr): - return long(expr) # noqa pylint:disable=undefined-variable + return long(expr) # noqa def map_Indexed(self, expr): # noqa if len(expr.args) == 2: diff --git a/pymbolic/mapper/constant_converter.py b/pymbolic/mapper/constant_converter.py index 58630531..28ddd5fb 100644 --- a/pymbolic/mapper/constant_converter.py +++ b/pymbolic/mapper/constant_converter.py @@ -45,8 +45,8 @@ def __init__(self, real_type, complex_type=None, integer_type=None): complex_type = np.complex64 elif real_type is np.float64: complex_type = np.complex128 - elif real_type is np.float128: # pylint:disable=no-member - complex_type = np.complex256 # pylint:disable=no-member + elif real_type is np.float128: + complex_type = np.complex256 else: raise TypeError("unable to determine corresponding complex type " f"for '{real_type.__name__}'") diff --git a/pymbolic/mapper/evaluator.py b/pymbolic/mapper/evaluator.py index e024e636..bf4ed96e 100644 --- a/pymbolic/mapper/evaluator.py +++ b/pymbolic/mapper/evaluator.py @@ -153,8 +153,6 @@ def map_right_shift(self, expr: p.RightShift) -> ResultT: @override def map_bitwise_not(self, expr: p.BitwiseNot) -> ResultT: - # ??? Why, pylint, why ??? - # pylint: disable=invalid-unary-operand-type return ~self.rec(expr.child) # type: ignore[operator] @override diff --git a/pymbolic/parser.py b/pymbolic/parser.py index 39ca0894..752b920d 100644 --- a/pymbolic/parser.py +++ b/pymbolic/parser.py @@ -264,7 +264,7 @@ def parse_prefix(self, pstate: LexIterator): left_exp = self.parse_expression(pstate, _PREC_UNARY) elif pstate.is_next(_minus): pstate.advance() - left_exp = -self.parse_expression(pstate, _PREC_UNARY) # pylint:disable=invalid-unary-operand-type + left_exp = -self.parse_expression(pstate, _PREC_UNARY) elif pstate.is_next(_not): pstate.advance() from pymbolic.primitives import LogicalNot @@ -397,7 +397,7 @@ def parse_postfix(self, pstate.advance() right_exp = self.parse_arith_expression(pstate, _PREC_PLUS) assert is_arithmetic_expression(left_exp) - left_exp = primitives.Sum((left_exp, -right_exp)) # pylint:disable=invalid-unary-operand-type + left_exp = primitives.Sum((left_exp, -right_exp)) did_something = True elif next_tag is _times and min_precedence < _PREC_TIMES: pstate.advance() diff --git a/pymbolic/primitives.py b/pymbolic/primitives.py index 33f34975..d6d3781d 100644 --- a/pymbolic/primitives.py +++ b/pymbolic/primitives.py @@ -412,7 +412,7 @@ def __getinitargs__(self): raise NotImplementedError @_classproperty - def __match_args__(cls): # noqa: N805 # pylint: disable=no-self-argument + def __match_args__(cls): # noqa: N805 return cls.init_arg_names @property diff --git a/test/test_pymbolic.py b/test/test_pymbolic.py index b5a51d46..276b4215 100644 --- a/test/test_pymbolic.py +++ b/test/test_pymbolic.py @@ -173,7 +173,7 @@ def test_sympy_interaction(): x, y = sp.symbols("x y") f = sp.Function("f") - s1_expr = 1/f(x/sp.sqrt(x**2+y**2)).diff(x, 5) # pylint:disable=not-callable + s1_expr = 1/f(x/sp.sqrt(x**2+y**2)).diff(x, 5) from pymbolic.interop.sympy import PymbolicToSympyMapper, SympyToPymbolicMapper s2p = SympyToPymbolicMapper() From 17d4821c753bcfec65a3b976194193d1159f64c2 Mon Sep 17 00:00:00 2001 From: Alexandru Fikl Date: Fri, 26 Sep 2025 11:00:19 +0300 Subject: [PATCH 3/4] chore: remove unused mypy comments --- pymbolic/mapper/__init__.py | 10 ++++----- pymbolic/mapper/dependency.py | 3 +-- pymbolic/mapper/evaluator.py | 42 +++++++++++++++++------------------ pymbolic/parser.py | 2 +- pymbolic/primitives.py | 8 +++---- 5 files changed, 30 insertions(+), 35 deletions(-) diff --git a/pymbolic/mapper/__init__.py b/pymbolic/mapper/__init__.py index 1f057387..cbc456f1 100644 --- a/pymbolic/mapper/__init__.py +++ b/pymbolic/mapper/__init__.py @@ -146,8 +146,7 @@ class UnsupportedExpressionError(ValueError): ResultT = TypeVar("ResultT") # This ParamSpec could be marked contravariant (just like Callable is contravariant -# in its arguments). As of mypy 1.14/Py3.13 (Nov 2024), mypy complains of as-yet -# undefined semantics, so it's probably too soon. +# in its arguments). Unfortunately, this is not yet supported by type checkers. P = ParamSpec("P") @@ -1058,7 +1057,7 @@ def map_list(self, ) -> Expression: # True fact: lists aren't expressions - return [self.rec(child, *args, **kwargs) for child in expr] # type: ignore[return-value] + return [self.rec(child, *args, **kwargs) for child in expr] @override def map_tuple(self, @@ -1081,8 +1080,7 @@ def map_numpy_array(self, for i in ndindex(expr.shape): result[i] = self.rec(expr[i], *args, **kwargs) - # True fact: ndarrays aren't expressions - return result # type: ignore[return-value] + return result @override def map_multivector(self, @@ -1091,7 +1089,7 @@ def map_multivector(self, ) -> Expression: # True fact: MultiVectors aren't expressions return expr.map(lambda ch: cast("ArithmeticExpression", - self.rec(ch, *args, **kwargs))) # type: ignore[return-value] + self.rec(ch, *args, **kwargs))) def map_common_subexpression(self, expr: p.CommonSubexpression, diff --git a/pymbolic/mapper/dependency.py b/pymbolic/mapper/dependency.py index 63bce1f9..168954e9 100644 --- a/pymbolic/mapper/dependency.py +++ b/pymbolic/mapper/dependency.py @@ -146,8 +146,7 @@ def map_common_subexpression_uncached( if self.include_cses: return {expr} else: - # FIXME: These look like mypy bugs, revisit - return Collector.map_common_subexpression(self, expr, *args, **kwargs) # type: ignore[return-value, arg-type] + return Collector.map_common_subexpression(self, expr, *args, **kwargs) @override def map_slice( diff --git a/pymbolic/mapper/evaluator.py b/pymbolic/mapper/evaluator.py index bf4ed96e..aabc7772 100644 --- a/pymbolic/mapper/evaluator.py +++ b/pymbolic/mapper/evaluator.py @@ -99,7 +99,7 @@ def map_variable(self, expr: p.Variable) -> ResultT: @override def map_call(self, expr: p.Call) -> ResultT: - return self.rec(expr.function)(*[self.rec(par) for par in expr.parameters]) # type: ignore[operator] + return self.rec(expr.function)(*[self.rec(par) for par in expr.parameters]) @override def map_call_with_kwargs(self, expr: p.CallWithKwargs) -> ResultT: @@ -108,11 +108,11 @@ def map_call_with_kwargs(self, expr: p.CallWithKwargs) -> ResultT: k: self.rec(v) for k, v in expr.kw_parameters.items()} - return self.rec(expr.function)(*args, **kwargs) # type: ignore[operator] + return self.rec(expr.function)(*args, **kwargs) @override def map_subscript(self, expr: p.Subscript) -> ResultT: - return self.rec(expr.aggregate)[self.rec(expr.index)] # type: ignore[index] + return self.rec(expr.aggregate)[self.rec(expr.index)] @override def map_lookup(self, expr: p.Lookup) -> ResultT: @@ -120,7 +120,7 @@ def map_lookup(self, expr: p.Lookup) -> ResultT: @override def map_sum(self, expr: p.Sum) -> ResultT: - return sum(self.rec(child) for child in expr.children) # type: ignore[return-value, misc] + return sum(self.rec(child) for child in expr.children) @override def map_product(self, expr: p.Product) -> ResultT: @@ -129,31 +129,31 @@ def map_product(self, expr: p.Product) -> ResultT: @override def map_quotient(self, expr: p.Quotient) -> ResultT: - return self.rec(expr.numerator) / self.rec(expr.denominator) # type: ignore[operator] + return self.rec(expr.numerator) / self.rec(expr.denominator) @override def map_floor_div(self, expr: p.FloorDiv) -> ResultT: - return self.rec(expr.numerator) // self.rec(expr.denominator) # type: ignore[operator] + return self.rec(expr.numerator) // self.rec(expr.denominator) @override def map_remainder(self, expr: p.Remainder) -> ResultT: - return self.rec(expr.numerator) % self.rec(expr.denominator) # type: ignore[operator] + return self.rec(expr.numerator) % self.rec(expr.denominator) @override def map_power(self, expr: p.Power) -> ResultT: - return self.rec(expr.base) ** self.rec(expr.exponent) # type: ignore[operator] + return self.rec(expr.base) ** self.rec(expr.exponent) @override def map_left_shift(self, expr: p.LeftShift) -> ResultT: - return self.rec(expr.shiftee) << self.rec(expr.shift) # type: ignore[operator] + return self.rec(expr.shiftee) << self.rec(expr.shift) @override def map_right_shift(self, expr: p.RightShift) -> ResultT: - return self.rec(expr.shiftee) >> self.rec(expr.shift) # type: ignore[operator] + return self.rec(expr.shiftee) >> self.rec(expr.shift) @override def map_bitwise_not(self, expr: p.BitwiseNot) -> ResultT: - return ~self.rec(expr.child) # type: ignore[operator] + return ~self.rec(expr.child) @override def map_bitwise_or(self, expr: p.BitwiseOr) -> ResultT: @@ -168,20 +168,20 @@ def map_bitwise_and(self, expr: p.BitwiseAnd) -> ResultT: return reduce(op.and_, (self.rec(ch) for ch in expr.children)) @override - def map_logical_not(self, expr: p.LogicalNot) -> bool: # type: ignore[override] + def map_logical_not(self, expr: p.LogicalNot) -> bool: return not self.rec(expr.child) @override - def map_logical_or(self, expr: p.LogicalOr) -> bool: # type: ignore[override] + def map_logical_or(self, expr: p.LogicalOr) -> bool: return any(self.rec(ch) for ch in expr.children) @override - def map_logical_and(self, expr: p.LogicalAnd) -> bool: # type: ignore[override] + def map_logical_and(self, expr: p.LogicalAnd) -> bool: return all(self.rec(ch) for ch in expr.children) @override def map_list(self, expr: list[Expression]) -> ResultT: - return [self.rec(child) for child in expr] # type: ignore[return-value] + return [self.rec(child) for child in expr] @override def map_numpy_array(self, expr: NDArray[np.generic]) -> ResultT: @@ -189,11 +189,11 @@ def map_numpy_array(self, expr: NDArray[np.generic]) -> ResultT: result = numpy.empty(expr.shape, dtype=object) for i in ndindex(expr.shape): result[i] = self.rec(expr[i]) - return result # type: ignore[return-value] + return result @override def map_multivector(self, expr: MultiVector) -> ResultT: - return expr.map(lambda ch: self.rec(ch)) # type: ignore[return-value] + return expr.map(lambda ch: self.rec(ch)) @override def map_common_subexpression_uncached(self, expr: p.CommonSubexpression) -> ResultT: @@ -214,21 +214,21 @@ def map_comparison(self, expr: p.Comparison) -> ResultT: @override def map_min(self, expr: p.Min) -> ResultT: - return min(self.rec(child) for child in expr.children) # type: ignore[type-var] + return min(self.rec(child) for child in expr.children) @override def map_max(self, expr: p.Max) -> ResultT: - return max(self.rec(child) for child in expr.children) # type: ignore[type-var] + return max(self.rec(child) for child in expr.children) @override def map_tuple(self, expr: tuple[Expression, ...]) -> ResultT: - return tuple([self.rec(child) for child in expr]) # type: ignore[return-value] + return tuple([self.rec(child) for child in expr]) @override def map_nan(self, expr: p.NaN) -> ResultT: if expr.data_type is None: from math import nan - return nan # type:ignore[return-value] + return nan else: return expr.data_type(float("nan")) diff --git a/pymbolic/parser.py b/pymbolic/parser.py index 752b920d..90322d4c 100644 --- a/pymbolic/parser.py +++ b/pymbolic/parser.py @@ -126,7 +126,7 @@ class FinalizedTuple(tuple, FinalizedContainer): class FinalizedList(list, FinalizedContainer): @memoize_method - def __hash__(self) -> int: # type: ignore[override] + def __hash__(self) -> int: result = hash(type(self).__name__) for it in self: result ^= hash(it) diff --git a/pymbolic/primitives.py b/pymbolic/primitives.py index d6d3781d..f3bc0d22 100644 --- a/pymbolic/primitives.py +++ b/pymbolic/primitives.py @@ -592,7 +592,7 @@ def __call__(self, *args, **kwargs) -> Call | CallWithKwargs: if not TYPE_CHECKING: # Subscript has an attribute 'index' which can't coexist with this. - # Thus we're hiding this from mypy until it goes away. + # Thus we're hiding this from type checkers until it goes away. def index(self, subscript: ExpressionNode) -> ExpressionNode: """Return an expression representing ``self[subscript]``. @@ -1023,7 +1023,7 @@ def {cls.__name__}_setstate(self, state): # set a marker to detect classes whose subclasses may not be expr_dataclasses # type ignore because we don't want to announce the existence of this to the world. - cls._is_expr_dataclass = True # type: ignore[attr-defined] + cls._is_expr_dataclass = True # {{{ assign mapper_method @@ -1075,10 +1075,8 @@ def map_cls(cls: type[T]) -> type[T]: # We provide __eq__/__hash__ below, don't redundantly generate it. dc_cls = dataclass(init=init, eq=False, frozen=__debug__, repr=False)(cls) - # FIXME: I'm not sure how to tell mypy that dc_cls is type[DataclassInstance] - # It should just understand that? _augment_expression_dataclass( - dc_cls, # type: ignore[arg-type] + dc_cls, generate_eq=eq and "__eq__" not in cls.__dict__, generate_hash=hash and "__hash__" not in cls.__dict__, ) From ae6f44d4cce520841eceb6ffb35311917b596adb Mon Sep 17 00:00:00 2001 From: Alexandru Fikl Date: Fri, 26 Sep 2025 11:10:49 +0300 Subject: [PATCH 4/4] chore: update bare noqa comments --- pymbolic/__init__.py | 2 +- pymbolic/algorithm.py | 8 ++++---- pymbolic/interop/ast.py | 26 +++++++++++++------------- pymbolic/interop/common.py | 18 +++++++++--------- pymbolic/interop/maxima.py | 4 ++-- pymbolic/interop/symengine.py | 8 ++++---- pymbolic/interop/sympy.py | 10 +++++----- pymbolic/maxima.py | 5 ++++- pymbolic/primitives.py | 2 +- pymbolic/sympy_interface.py | 5 ++++- test/test_pymbolic.py | 2 +- 11 files changed, 48 insertions(+), 42 deletions(-) diff --git a/pymbolic/__init__.py b/pymbolic/__init__.py index b32e3ba0..d4484f15 100644 --- a/pymbolic/__init__.py +++ b/pymbolic/__init__.py @@ -69,7 +69,7 @@ RealNumber, Scalar, ) -from pymbolic.version import VERSION_TEXT as __version__ # noqa +from pymbolic.version import VERSION_TEXT as __version__ # noqa: F401,N811 __all__ = ( diff --git a/pymbolic/algorithm.py b/pymbolic/algorithm.py index 7a175d1e..8150d801 100644 --- a/pymbolic/algorithm.py +++ b/pymbolic/algorithm.py @@ -117,12 +117,12 @@ def extended_euclidean(q, r): p, a, b = extended_euclidean(r, q) return p, b, a - Q = 1, 0 # noqa - R = 0, 1 # noqa + Q = 1, 0 # noqa: N806 + R = 0, 1 # noqa: N806 while r: quot, t = divmod(q, r) - T = Q[0] - quot*R[0], Q[1] - quot*R[1] # noqa + T = Q[0] - quot*R[0], Q[1] - quot*R[1] # noqa: N806 q, r = r, t Q, R = R, T # noqa: N806 @@ -299,7 +299,7 @@ def wrap_intermediate_with_level(level: int, x): # }}} -def csr_matrix_multiply(S, x): # noqa +def csr_matrix_multiply(S, x): # noqa: N803 """Multiplies a :class:`scipy.sparse.csr_matrix` S by an object-array vector x. """ h, _w = S.shape diff --git a/pymbolic/interop/ast.py b/pymbolic/interop/ast.py index 5adb0ad9..4255a813 100644 --- a/pymbolic/interop/ast.py +++ b/pymbolic/interop/ast.py @@ -138,7 +138,7 @@ class ASTToPymbolic(ASTMapper): ast.BitAnd: p.BitwiseAnd, } - def map_BinOp(self, expr): # noqa + def map_BinOp(self, expr): # noqa: N802 try: op_constructor = self.bin_op_map[type(expr.op)] except KeyError: @@ -155,7 +155,7 @@ def map_BinOp(self, expr): # noqa ast.USub: _neg, } - def map_UnaryOp(self, expr): # noqa + def map_UnaryOp(self, expr): # noqa: N802 try: op_constructor = self.unary_op_map[type(expr.op)] except KeyError: @@ -165,7 +165,7 @@ def map_UnaryOp(self, expr): # noqa return op_constructor(self.rec(expr.operand)) - def map_IfExp(self, expr): # noqa + def map_IfExp(self, expr): # noqa: N802 # (expr test, expr body, expr orelse) return p.If(self.rec(expr.test), self.rec(expr.body), self.rec(expr.orelse)) @@ -182,7 +182,7 @@ def map_IfExp(self, expr): # noqa # NotIn } - def map_Compare(self, expr): # noqa + def map_Compare(self, expr): # noqa: N802 # (expr left, cmpop* ops, expr* comparators) op, = expr.ops @@ -198,7 +198,7 @@ def map_Compare(self, expr): # noqa return p.Comparison(self.rec(expr.left), comp, self.rec(right)) - def map_Call(self, expr): # noqa + def map_Call(self, expr): # noqa: N802 # (expr func, expr* args, keyword* keywords) func = self.rec(expr.func) args = tuple([self.rec(arg) for arg in expr.args]) @@ -210,25 +210,25 @@ def map_Call(self, expr): # noqa else: return p.Call(func, args) - def map_Num(self, expr): # noqa + def map_Num(self, expr): # noqa: N802 # (object n) -- a number as a PyObject. return expr.n - def map_Str(self, expr): # noqa + def map_Str(self, expr): # noqa: N802 return expr.s - def map_Bytes(self, expr): # noqa + def map_Bytes(self, expr): # noqa: N802 return expr.s - def map_Constant(self, expr): # noqa + def map_Constant(self, expr): # noqa: N802 # (singleton value) return expr.value - def map_Attribute(self, expr): # noqa + def map_Attribute(self, expr): # noqa: N802 # (expr value, identifier attr, expr_context ctx) return p.Lookup(self.rec(expr.value), expr.attr) - def map_Subscript(self, expr): # noqa + def map_Subscript(self, expr): # noqa: N802 # (expr value, slice slice, expr_context ctx) def none_or_rec(x): if x is None: @@ -250,11 +250,11 @@ def none_or_rec(x): # def map_Starred(self, expr): - def map_Name(self, expr): # noqa + def map_Name(self, expr): # noqa: N802 # (identifier id, expr_context ctx) return p.Variable(expr.id) - def map_Tuple(self, expr): # noqa + def map_Tuple(self, expr): # noqa: N802 # (expr* elts, expr_context ctx) return tuple([self.rec(ti) for ti in expr.elts]) diff --git a/pymbolic/interop/common.py b/pymbolic/interop/common.py index 8add4c1f..b48a00a5 100644 --- a/pymbolic/interop/common.py +++ b/pymbolic/interop/common.py @@ -75,10 +75,10 @@ def function_name(self, expr): # }}} - def map_Symbol(self, expr): # noqa + def map_Symbol(self, expr): # noqa: N802 return prim.Variable(str(expr.name)) - def map_Rational(self, expr): # noqa + def map_Rational(self, expr): # noqa: N802 p, q = expr.p, expr.q num = self.rec(p) @@ -88,30 +88,30 @@ def map_Rational(self, expr): # noqa return num return prim.Quotient(num, denom) - def map_Integer(self, expr): # noqa + def map_Integer(self, expr): # noqa: N802 return int(expr) - def map_Add(self, expr): # noqa + def map_Add(self, expr): # noqa: N802 return prim.Sum(tuple([self.rec(arg) for arg in expr.args])) - def map_Mul(self, expr): # noqa + def map_Mul(self, expr): # noqa: N802 return prim.Product(tuple([self.rec(arg) for arg in expr.args])) - def map_Pow(self, expr): # noqa + def map_Pow(self, expr): # noqa: N802 base, exp = expr.args return prim.Power(self.rec(base), self.rec(exp)) - def map_Subs(self, expr): # noqa + def map_Subs(self, expr): # noqa: N802 return prim.Substitution(self.rec(expr.expr), tuple([v.name for v in expr.variables]), tuple([self.rec(v) for v in expr.point]), ) - def map_Derivative(self, expr): # noqa + def map_Derivative(self, expr): # noqa: N802 return prim.Derivative(self.rec(expr.expr), tuple([v.name for v in expr.variables])) - def map_UnevaluatedExpr(self, expr): # noqa + def map_UnevaluatedExpr(self, expr): # noqa: N802 return self.rec(expr.args[0]) def not_supported(self, expr): diff --git a/pymbolic/interop/maxima.py b/pymbolic/interop/maxima.py index bdde56e3..db77213d 100644 --- a/pymbolic/interop/maxima.py +++ b/pymbolic/interop/maxima.py @@ -289,9 +289,9 @@ def __init__(self, executable="maxima", timeout=30): def _initialize(self): - PEXPECT_SHELL = "bash" # noqa + PEXPECT_SHELL = "bash" # noqa: N806 - PRE_MAXIMA_COMMANDS = ( # noqa + PRE_MAXIMA_COMMANDS = ( # noqa: N806 # Makes long line inputs possible. ("stty -icanon",) ) diff --git a/pymbolic/interop/symengine.py b/pymbolic/interop/symengine.py index 4992e8bc..c4909bd6 100644 --- a/pymbolic/interop/symengine.py +++ b/pymbolic/interop/symengine.py @@ -46,7 +46,7 @@ class SymEngineToPymbolicMapper(SympyLikeToPymbolicMapper): - def map_Pow(self, expr): # noqa + def map_Pow(self, expr): # noqa: N802 # SymEngine likes to use as e**a to express exp(a); we undo that here. base, exp = expr.args if base == symengine.E: @@ -54,17 +54,17 @@ def map_Pow(self, expr): # noqa else: return prim.Power(self.rec(base), self.rec(exp)) - def map_Constant(self, expr): # noqa + def map_Constant(self, expr): # noqa: N802 return self.rec(expr.n()) map_Complex = map_Constant # noqa: N815 - def map_ComplexDouble(self, expr): # noqa + def map_ComplexDouble(self, expr): # noqa: N802 return complex(expr) map_RealDouble = SympyLikeToPymbolicMapper.to_float # noqa: N815 - def map_Piecewise(self, expr): # noqa + def map_Piecewise(self, expr): # noqa: N802 # We only handle piecewises with 2 statements! if not len(expr.args) == 4: raise NotImplementedError diff --git a/pymbolic/interop/sympy.py b/pymbolic/interop/sympy.py index db866bc4..c0311ae5 100644 --- a/pymbolic/interop/sympy.py +++ b/pymbolic/interop/sympy.py @@ -47,7 +47,7 @@ class SympyToPymbolicMapper(SympyLikeToPymbolicMapper): - def map_ImaginaryUnit(self, expr): # noqa + def map_ImaginaryUnit(self, expr): # noqa: N802 return 1j map_Float = SympyLikeToPymbolicMapper.to_float # noqa: N815 @@ -59,9 +59,9 @@ def function_name(self, expr): # only called for Py2 def map_long(self, expr): - return long(expr) # noqa + return long(expr) # noqa: F821 - def map_Indexed(self, expr): # noqa + def map_Indexed(self, expr): # noqa: N802 if len(expr.args) == 2: return prim.Subscript( self.rec(expr.args[0].args[0]), @@ -73,11 +73,11 @@ def map_Indexed(self, expr): # noqa tuple([self.rec(i) for i in expr.args[1:]]) ) - def map_CSE(self, expr): # noqa + def map_CSE(self, expr): # noqa: N802 return prim.CommonSubexpression( self.rec(expr.args[0]), expr.prefix, expr.scope) - def map_Piecewise(self, expr): # noqa + def map_Piecewise(self, expr): # noqa: N802 # We only handle piecewises with 2 arguments! if not len(expr.args) == 2: raise NotImplementedError diff --git a/pymbolic/maxima.py b/pymbolic/maxima.py index 3eee265e..8fb7a74b 100644 --- a/pymbolic/maxima.py +++ b/pymbolic/maxima.py @@ -1,6 +1,9 @@ -from pymbolic.interop.maxima import * # noqa +from __future__ import annotations from warnings import warn +from pymbolic.interop.maxima import * # noqa: F403 + + warn("pymbolic.maxima is deprecated. Use pymbolic.interop.maxima instead", DeprecationWarning, stacklevel=1) diff --git a/pymbolic/primitives.py b/pymbolic/primitives.py index f3bc0d22..7d25a3c9 100644 --- a/pymbolic/primitives.py +++ b/pymbolic/primitives.py @@ -1502,7 +1502,7 @@ class If(ExpressionNode): # {{{ misc stuff -class cse_scope: # noqa +class cse_scope: # noqa: N801 """Determines the lifetime for the saved value of a :class:`CommonSubexpression`. .. attribute:: EVALUATION diff --git a/pymbolic/sympy_interface.py b/pymbolic/sympy_interface.py index 0b423751..cba0bdef 100644 --- a/pymbolic/sympy_interface.py +++ b/pymbolic/sympy_interface.py @@ -1,6 +1,9 @@ -from pymbolic.interop.sympy import * # noqa +from __future__ import annotations from warnings import warn +from pymbolic.interop.sympy import * # noqa: F403 + + warn("pymbolic.sympy_interface is deprecated. Use pymbolic.interop.sympy instead", DeprecationWarning, stacklevel=1) diff --git a/test/test_pymbolic.py b/test/test_pymbolic.py index 276b4215..850599b8 100644 --- a/test/test_pymbolic.py +++ b/test/test_pymbolic.py @@ -418,7 +418,7 @@ def test_geometric_algebra(dims): import numpy as np - from pymbolic.geometric_algebra import MultiVector as MV # noqa + from pymbolic.geometric_algebra import MultiVector as MV # noqa: N817 vec1 = MV(np.random.randn(dims)) vec2 = MV(np.random.randn(dims))