Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ruff SLF001 #483

Merged
merged 6 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,11 @@ lint.select = [
"F", # pyflakes rules - https://beta.ruff.rs/docs/rules/#pyflakes-f
"W", # pycodestyle warnings - https://beta.ruff.rs/docs/rules/#warning-w
"I001", # isort
"SLF", # self - https://docs.astral.sh/ruff/settings/#lintflake8-self
]

[tool.ruff.lint.per-file-ignores]
# By default, private member access is allowed in tests
# See https://github.com/DiamondLightSource/python-copier-template/issues/154
# Remove this line to forbid private member access in tests
"tests/**/*" = ["SLF001"]
2 changes: 1 addition & 1 deletion src/ophyd_async/core/_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ async def _check_config_sigs(self):
await signal.get_value()
except NotImplementedError:
raise Exception(
f"config signal {signal._name} must be connected before it is "
f"config signal {signal.name} must be connected before it is "
+ "passed to the detector"
)

Expand Down
7 changes: 4 additions & 3 deletions src/ophyd_async/core/_mock_signal_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@


def _get_mock_signal_backend(signal: Signal) -> MockSignalBackend:
assert isinstance(signal._backend, MockSignalBackend), (
backend = signal._backend # noqa:SLF001
assert isinstance(backend, MockSignalBackend), (
"Expected to receive a `MockSignalBackend`, instead "
f" received {type(signal._backend)}. "
f" received {type(backend)}. "
)
return signal._backend
return backend


def set_mock_value(signal: Signal[T], value: T):
Expand Down
2 changes: 1 addition & 1 deletion tests/core/test_subset_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from ophyd_async.core import SubsetEnum
from ophyd_async.epics.signal import epics_signal_rw

# I think we want to allow these as calling these is only needed for tests?
# Allow these imports from private modules for tests
from ophyd_async.epics.signal._aioca import make_converter as aioca_make_converter
from ophyd_async.epics.signal._p4p import make_converter as p4p_make_converter

Expand Down
2 changes: 1 addition & 1 deletion tests/fastcs/panda/test_panda_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
NotConnected,
)
from ophyd_async.epics.pvi import create_children_from_annotations, fill_pvi_entries
from ophyd_async.epics.pvi._pvi import _PVIEntry # Allow as edge case for typing
from ophyd_async.epics.pvi._pvi import _PVIEntry # noqa
from ophyd_async.fastcs.panda import (
PcapBlock,
PulseBlock,
Expand Down
Loading