Skip to content

Commit

Permalink
enable RUF100, check 'noqa' decl are still needed
Browse files Browse the repository at this point in the history
  • Loading branch information
marscher committed Jan 3, 2023
1 parent 022356d commit 84ec757
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 39 deletions.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ select = [
'T2', # flake8-print
'I001', # isort
'ICN', # import conventions, e.g. import numpy as np
#'B950' # not yet implemented by Ruff.
#'B950', # not yet implemented by Ruff.
'RUF100', # ensure 'noqa' declarations are still valid.
]

# Allow pydocstyle violations in certain areas.
Expand Down
2 changes: 1 addition & 1 deletion weldx/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pathlib import Path as _Path

import pint
import pint_xarray # noqa: F401 # pylint: disable=W0611
import pint_xarray

META_ATTR = "wx_metadata"
"""The default attribute to store weldx metadata."""
Expand Down
4 changes: 2 additions & 2 deletions weldx/core/time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,11 @@ def interp_time(
def plot(
self,
time: Union[pd.TimedeltaIndex, pint.Quantity] = None,
axes: "matplotlib.axes.Axes" = None, # noqa: F821
axes: "matplotlib.axes.Axes" = None,
data_name: str = "values",
time_unit: UnitLike = None,
**mpl_kwargs,
) -> "matplotlib.axes.Axes": # noqa: F821
) -> "matplotlib.axes.Axes":
"""Plot the `TimeSeries`.
Parameters
Expand Down
10 changes: 5 additions & 5 deletions weldx/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -1453,7 +1453,7 @@ def plot(
if isinstance(color, str): # single color
color = [color] * len(raster_data)

for segment, c in zip(raster_data, color): # noqa: B905
for segment, c in zip(raster_data, color):
ax.plot(segment[0], segment[1], line_style, label=label, color=c)

@property
Expand Down Expand Up @@ -2511,13 +2511,13 @@ def plot(
self,
profile_raster_width: QuantityLike = "1mm",
trace_raster_width: QuantityLike = "50mm",
axes: "matplotlib.axes.Axes" = None, # noqa: F821
axes: "matplotlib.axes.Axes" = None,
color: Union[int, tuple[int, int, int], tuple[float, float, float]] = None,
label: str = None,
limits: "weldx.visualization.types.types_limits" = None,
show_wireframe: bool = True,
backend: str = "mpl",
) -> "matplotlib.axes.Axes": # noqa: F821
) -> "matplotlib.axes.Axes":
"""Plot the geometry.
Parameters
Expand Down Expand Up @@ -2874,13 +2874,13 @@ def limits(self) -> np.ndarray:

def plot(
self,
axes: "matplotlib.axes.Axes" = None, # noqa: F821
axes: "matplotlib.axes.Axes" = None,
color: Union[int, tuple[int, int, int], tuple[float, float, float]] = None,
label: str = None,
show_wireframe: bool = True,
limits: "weldx.visualization.types.types_limits" = None,
backend: str = "mpl",
) -> "matplotlib.axes.Axes": # noqa: F821
) -> "matplotlib.axes.Axes":
"""Plot the spatial data.
Parameters
Expand Down
6 changes: 3 additions & 3 deletions weldx/measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import annotations

from dataclasses import dataclass, field
from typing import TYPE_CHECKING, Union # noqa: F401
from typing import TYPE_CHECKING, Union
from warnings import warn

import pint
Expand Down Expand Up @@ -48,11 +48,11 @@ def __post_init__(self):
def plot(
self,
time: Union[TimedeltaIndex, Quantity] = None,
axes: "matplotlib.axes.Axes" = None, # noqa: F821
axes: "matplotlib.axes.Axes" = None,
data_name: str = "values",
time_unit: Union[str, Unit] = None,
**mpl_kwargs,
) -> "matplotlib.axes.Axes": # noqa: F821
) -> "matplotlib.axes.Axes":
"""Plot the time dependent data of the `Signal`.
Parameters
Expand Down
20 changes: 10 additions & 10 deletions weldx/tests/asdf_tests/test_weldx_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,43 +25,43 @@
class _ReadOnlyFile:
"""Simulate a read-only file."""

def __init__(self, tmpdir): # noqa: D107
def __init__(self, tmpdir):
fn = tempfile.mktemp(suffix=".asdf", dir=tmpdir)
with open(fn, "wb") as fh:
asdf.AsdfFile(tree=dict(hi="there")).write_to(fh)
self.mode = "rb"
self.file_read_only = open(fn, mode=self.mode)

def read(self, *args, **kwargs): # noqa: D102
def read(self, *args, **kwargs):
return self.file_read_only.read(*args, **kwargs)

def readline(self, limit=-1): # noqa: D102
def readline(self, limit=-1):
return self.file_read_only.readline(limit)

@staticmethod
def readable(): # noqa: D102
def readable():
return True


class _WritableFile:
"""Example of a class implementing SupportsFileReadWrite."""

def __init__(self): # noqa: D107
def __init__(self):
self.to_wrap = BytesIO()

def read(self, *args, **kwargs): # noqa: D102
def read(self, *args, **kwargs):
return self.to_wrap.read(*args, **kwargs)

def readline(self, *args, **kwargs): # noqa: D102
def readline(self, *args, **kwargs):
return self.to_wrap.readline(*args, **kwargs)

def write(self, *args, **kwargs): # noqa: D102
def write(self, *args, **kwargs):
return self.to_wrap.write(*args, **kwargs)

def tell(self): # noqa: D102
def tell(self):
return self.to_wrap.tell()

def seek(self, *args, **kwargs): # noqa: D102
def seek(self, *args, **kwargs):
return self.to_wrap.seek(*args, **kwargs)

def flush(self):
Expand Down
4 changes: 2 additions & 2 deletions weldx/tests/test_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ def _default_dicts():
(1, 2),
],
)
def test_compare_nested_raise(a, b): # noqa: D102
def test_compare_nested_raise(a, b):
"""non-nested types should raise TypeError."""
with pytest.raises(TypeError):
ut.compare_nested(a, b)
Expand Down Expand Up @@ -583,7 +583,7 @@ def test_equip_modified(self): # noqa: D102
self.b["equipment"][0].name = "broken device"
assert not ut.compare_nested(self.a, self.b)

def test_coordinate_systems_modified(self): # noqa: D102
def test_coordinate_systems_modified(self):
"""Manipulate one CSM and check if it gets picked up by comparison."""
csm_org = self.a["coordinate_systems"]
csm_copy = self.b["coordinate_systems"]
Expand Down
8 changes: 4 additions & 4 deletions weldx/tests/transformations/test_cs_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
import pandas as pd
import pytest
import xarray as xr
from pandas import TimedeltaIndex as TDI # noqa
from pandas import Timestamp as TS # noqa
from pandas import TimedeltaIndex as TDI
from pandas import Timestamp as TS

import weldx.transformations as tf
from weldx.constants import Q_
from weldx.core import MathematicalExpression, TimeSeries
from weldx.geometry import SpatialData
from weldx.tests._helpers import get_test_name, matrix_is_close
from weldx.time import Time, types_time_like, types_timestamp_like
from weldx.transformations import CoordinateSystemManager as CSM # noqa
from weldx.transformations import LocalCoordinateSystem as LCS # noqa
from weldx.transformations import CoordinateSystemManager as CSM
from weldx.transformations import LocalCoordinateSystem as LCS
from weldx.transformations import WXRotation

from ._util import check_coordinate_system, check_cs_close, r_mat_x, r_mat_y, r_mat_z
Expand Down
6 changes: 3 additions & 3 deletions weldx/tests/transformations/test_local_cs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import pint
import pytest
import xarray as xr
from pandas import TimedeltaIndex as TDI # noqa
from pandas import Timestamp as TS # noqa
from pandas import TimedeltaIndex as TDI
from pandas import Timestamp as TS
from pandas import date_range
from pint import DimensionalityError

Expand All @@ -20,7 +20,7 @@
from weldx.core import MathematicalExpression, TimeSeries
from weldx.tests._helpers import get_test_name
from weldx.time import Time
from weldx.transformations import LocalCoordinateSystem as LCS # noqa
from weldx.transformations import LocalCoordinateSystem as LCS
from weldx.transformations import WXRotation

from ._util import check_coordinate_system, check_cs_close, r_mat_y, r_mat_z
Expand Down
4 changes: 2 additions & 2 deletions weldx/transformations/cs_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,7 @@ def get_cs(
from networkx import shortest_path

path = shortest_path(self.graph, coordinate_system_name, reference_system_name)
path_edges = list(zip(path[:-1], path[1:])) # noqa: B905
path_edges = list(zip(path[:-1], path[1:]))

# handle time inputs
if time_ref is None:
Expand Down Expand Up @@ -1515,7 +1515,7 @@ def _is_edge_time_dependent(edge):
def plot(
self,
backend: str = "mpl",
axes: "matplotlib.axes.Axes" = None, # noqa: F821
axes: "matplotlib.axes.Axes" = None,
reference_system: str = None,
coordinate_systems: list[str] = None,
data_sets: list[str] = None,
Expand Down
2 changes: 1 addition & 1 deletion weldx/transformations/local_cs.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ def invert(self) -> LocalCoordinateSystem:

def plot(
self,
axes: "matplotlib.axes.Axes" = None, # noqa: F821
axes: "matplotlib.axes.Axes" = None,
color: str = None,
label: str = None,
time: types_time_like = None,
Expand Down
8 changes: 4 additions & 4 deletions weldx/transformations/rotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class WXRotation(_Rotation):
"""

@classmethod
def from_quat(cls, quat: npt.ArrayLike) -> "WXRotation": # noqa
def from_quat(cls, quat: npt.ArrayLike) -> "WXRotation":
"""Initialize from quaternions.
See `scipy.spatial.transform.Rotation.from_quat` docs for details.
Expand All @@ -35,7 +35,7 @@ def from_quat(cls, quat: npt.ArrayLike) -> "WXRotation": # noqa
return rot

@classmethod
def from_matrix(cls, matrix: npt.ArrayLike) -> "WXRotation": # noqa
def from_matrix(cls, matrix: npt.ArrayLike) -> "WXRotation":
"""Initialize from matrix.
See `scipy.spatial.transform.Rotation.from_matrix` docs for details.
Expand All @@ -45,7 +45,7 @@ def from_matrix(cls, matrix: npt.ArrayLike) -> "WXRotation": # noqa
return rot

@classmethod
def from_rotvec(cls, rotvec: npt.ArrayLike) -> "WXRotation": # noqa
def from_rotvec(cls, rotvec: npt.ArrayLike) -> "WXRotation":
"""Initialize from rotation vector.
See `scipy.spatial.transform.Rotation.from_rotvec` docs for details.
Expand All @@ -61,7 +61,7 @@ def from_euler(
seq: str,
angles: Union[pint.Quantity, npt.ArrayLike],
degrees: bool = False,
) -> "WXRotation": # noqa
) -> "WXRotation":
"""Initialize from euler angles.
See `scipy.spatial.transform.Rotation.from_euler` docs for details.
Expand Down
2 changes: 1 addition & 1 deletion weldx/welding/groove/iso_9692_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def _get_bounds(points):

def _compute_cross_sect_shape_points(
points: list[list[Union[Point2D, tuple]]]
) -> pint.Quantity: # noqa
) -> pint.Quantity:
# Assumes that we have two separate shapes for each workpiece
# 1. compute the total area of all workpieces
# 2. compute bounding box of all pieces (this includes the rift)
Expand Down

0 comments on commit 84ec757

Please sign in to comment.