diff --git a/pyproject.toml b/pyproject.toml index f15f56ee25..83dcb9ca2e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"] diff --git a/src/ophyd_async/core/_detector.py b/src/ophyd_async/core/_detector.py index cdc9fb324e..b3f9e53ca9 100644 --- a/src/ophyd_async/core/_detector.py +++ b/src/ophyd_async/core/_detector.py @@ -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" ) diff --git a/src/ophyd_async/core/_mock_signal_utils.py b/src/ophyd_async/core/_mock_signal_utils.py index 7026b4e842..767ebfa125 100644 --- a/src/ophyd_async/core/_mock_signal_utils.py +++ b/src/ophyd_async/core/_mock_signal_utils.py @@ -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): diff --git a/tests/core/test_subset_enum.py b/tests/core/test_subset_enum.py index dfdc7416dd..41af248aac 100644 --- a/tests/core/test_subset_enum.py +++ b/tests/core/test_subset_enum.py @@ -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 diff --git a/tests/fastcs/panda/test_panda_connect.py b/tests/fastcs/panda/test_panda_connect.py index d5d0900b3b..2685f3c66c 100644 --- a/tests/fastcs/panda/test_panda_connect.py +++ b/tests/fastcs/panda/test_panda_connect.py @@ -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,