Skip to content

Commit

Permalink
add linter options to check for unused arguments and variables, and a…
Browse files Browse the repository at this point in the history
…dd corresponding ignores
  • Loading branch information
rettigl committed Mar 22, 2024
1 parent d2517a9 commit ede8624
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 29 deletions.
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ lint.select = [
"E", # pycodestyle
"W", # pycodestyle
"PL", # pylint
"F841", # unused variable
"F401", # unused imports
"ARG", # unused arguments
]
lint.ignore = [
"E701", # Multiple statements on one line (colon)
Expand Down
4 changes: 2 additions & 2 deletions sed/calibrator/energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def update(refid, ranges):
ranges=ranges_slider,
)

def apply_func(apply: bool): # pylint: disable=unused-argument
def apply_func(apply: bool): # noqa: ARG001
self.add_ranges(
ranges_slider.value,
refid_slider.value,
Expand Down Expand Up @@ -1141,7 +1141,7 @@ def update(amplitude, x_center, y_center, **kwds):

fig.canvas.draw_idle()

def common_apply_func(apply: bool): # pylint: disable=unused-argument
def common_apply_func(apply: bool): # noqa: ARG001
self.correction = {}
self.correction["amplitude"] = correction["amplitude"]
self.correction["center"] = correction["center"]
Expand Down
10 changes: 5 additions & 5 deletions sed/calibrator/momentum.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def update(plane: int, width: int):
width=width_slider,
)

def apply_fun(apply: bool): # pylint: disable=unused-argument
def apply_fun(apply: bool): # noqa: ARG001
start = plane_slider.value
stop = plane_slider.value + width_slider.value

Expand Down Expand Up @@ -541,7 +541,7 @@ def onclick(event):

cid = fig.canvas.mpl_connect("button_press_event", onclick)

def apply_func(apply: bool): # pylint: disable=unused-argument
def apply_func(apply: bool): # noqa: ARG001
fig.canvas.mpl_disconnect(cid)

point_no_input.close()
Expand Down Expand Up @@ -1144,7 +1144,7 @@ def update(scale: float, xtrans: float, ytrans: float, angle: float):
angle=angle_slider,
)

def apply_func(apply: bool): # pylint: disable=unused-argument
def apply_func(apply: bool): # noqa: ARG001
if transformations.get("scale", 1) != 1:
self.coordinate_transform(
transform_type="scaling",
Expand Down Expand Up @@ -1457,7 +1457,7 @@ def update(
point_a_y: int,
point_b_x: int,
point_b_y: int,
k_distance: float, # pylint: disable=unused-argument
k_distance: float, # noqa: ARG001
):
fig.canvas.draw_idle()
marker_a.set_xdata(point_a_x)
Expand Down Expand Up @@ -1493,7 +1493,7 @@ def onclick(event):

cid = fig.canvas.mpl_connect("button_press_event", onclick)

def apply_func(apply: bool): # pylint: disable=unused-argument
def apply_func(apply: bool): # noqa: ARG001
point_a = [point_a_input_x.value, point_a_input_y.value]
point_b = [point_b_input_x.value, point_b_input_y.value]
calibration = self.calibrate(
Expand Down
9 changes: 4 additions & 5 deletions sed/loader/flash/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,6 @@ def parquet_handler(
load_parquet: bool = False,
save_parquet: bool = False,
force_recreate: bool = False,
**kwds,
) -> Tuple[dd.DataFrame, dd.DataFrame]:
"""
Handles loading and saving of parquet files based on the provided parameters.
Expand Down Expand Up @@ -836,7 +835,7 @@ def parquet_handler(

return dataframe_electron, dataframe_pulse

def parse_metadata(self, scicat_token: str = None, **kwds) -> dict:
def parse_metadata(self, scicat_token: str = None) -> dict:
"""Uses the MetadataRetriever class to fetch metadata from scicat for each run.
Returns:
Expand All @@ -854,12 +853,12 @@ def parse_metadata(self, scicat_token: str = None, **kwds) -> dict:

def get_count_rate(
self,
fids: Sequence[int] = None,
**kwds,
fids: Sequence[int] = None, # noqa: ARG002
**kwds, # noqa: ARG002
):
return None, None

def get_elapsed_time(self, fids=None, **kwds):
def get_elapsed_time(self, fids=None, **kwds): # noqa: ARG002
return None

def read_dataframe(
Expand Down
20 changes: 10 additions & 10 deletions sed/loader/generic/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ def read_dataframe(

def get_files_from_run_id(
self,
run_id: str,
folders: Union[str, Sequence[str]] = None,
extension: str = None,
**kwds,
run_id: str, # noqa: ARG002
folders: Union[str, Sequence[str]] = None, # noqa: ARG002
extension: str = None, # noqa: ARG002
**kwds, # noqa: ARG002
) -> List[str]:
"""Locate the files for a given run identifier.
Expand All @@ -120,10 +120,10 @@ def get_files_from_run_id(
"""
raise NotImplementedError

def get_count_rate( # Pylint: disable=unused_parameter
def get_count_rate(
self,
fids: Sequence[int] = None,
**kwds,
fids: Sequence[int] = None, # noqa: ARG002
**kwds, # noqa: ARG002
) -> Tuple[np.ndarray, np.ndarray]:
"""Create count rate data for the files specified in ``fids``.
Expand All @@ -139,10 +139,10 @@ def get_count_rate( # Pylint: disable=unused_parameter
# TODO
return None, None

def get_elapsed_time( # Pylint: disable=unused_parameter
def get_elapsed_time(
self,
fids: Sequence[int] = None,
**kwds,
fids: Sequence[int] = None, # noqa: ARG002
**kwds, # noqa: ARG002
) -> float:
"""Return the elapsed time in the files specified in ``fids``.
Expand Down
2 changes: 1 addition & 1 deletion sed/loader/mpes/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ def get_files_from_run_id(
run_id: str,
folders: Union[str, Sequence[str]] = None,
extension: str = "h5",
**kwds,
**kwds, # noqa: ARG002
) -> List[str]:
"""Locate the files for a given run identifier.
Expand Down
6 changes: 3 additions & 3 deletions sed/loader/sxp/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,12 +898,12 @@ def gather_metadata(self, metadata: dict = None) -> dict:

def get_count_rate(
self,
fids: Sequence[int] = None,
**kwds,
fids: Sequence[int] = None, # noqa: ARG002
**kwds, # noqa: ARG002
):
return None, None

def get_elapsed_time(self, fids=None, **kwds):
def get_elapsed_time(self, fids=None, **kwds): # noqa: ARG002
return None

def read_dataframe(
Expand Down
6 changes: 3 additions & 3 deletions tests/loader/flash/test_flash_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def mock_requests(requests_mock):


# Test cases for MetadataRetriever
def test_get_metadata(mock_requests):
def test_get_metadata(mock_requests): # noqa: ARG001
metadata_config = {
"scicat_url": "https://example.com",
"scicat_token": "fake_token",
Expand All @@ -22,7 +22,7 @@ def test_get_metadata(mock_requests):
assert metadata == {"fake": "data"}


def test_get_metadata_with_existing_metadata(mock_requests):
def test_get_metadata_with_existing_metadata(mock_requests): # noqa: ARG001
metadata_config = {
"scicat_url": "https://example.com",
"scicat_token": "fake_token",
Expand All @@ -34,7 +34,7 @@ def test_get_metadata_with_existing_metadata(mock_requests):
assert metadata == {"existing": "metadata", "fake": "data"}


def test_get_metadata_per_run(mock_requests):
def test_get_metadata_per_run(mock_requests): # noqa: ARG001
metadata_config = {
"scicat_url": "https://example.com",
"scicat_token": "fake_token",
Expand Down

0 comments on commit ede8624

Please sign in to comment.