diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index fd601444..265933b7 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -3,5 +3,10 @@ # will be requested for review when someone opens a pull request. * @tektronix/tm-devices-admin +/docs/ @tektronix/tm-devices-maintainers +/examples/ @tektronix/tm-devices-maintainers +/src/ @tektronix/tm-devices-maintainers +/tests/ @tektronix/tm-devices-maintainers + # Protect the configuration files .github/ @tektronix/tm-devices-admin diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e7a982f9..c9efddb9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,7 +34,7 @@ repos: - id: remove-tabs - id: forbid-tabs - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.27.2 + rev: 0.27.3 hooks: - id: check-readthedocs - id: check-dependabot @@ -121,15 +121,12 @@ repos: pass_filenames: false always_run: true args: [., --min=10] - - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.1.6 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.1.7 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] - - repo: https://github.com/psf/black - rev: 23.11.0 - hooks: - - id: black + - id: ruff-format - repo: https://github.com/PyCQA/docformatter rev: v1.7.0 # can't update due to https://github.com/PyCQA/docformatter/issues/174 hooks: diff --git a/CHANGELOG.md b/CHANGELOG.md index e17ecfde..8b6f992d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,10 @@ ______________________________________________________________________ Things to be included in the next release go here. +### Changed + +- Switched to ruff's formatter instead of black's formatter for python code + ______________________________________________________________________ ## v1.1.0 (2023-12-07) diff --git a/README.rst b/README.rst index 8e356170..d6d13625 100644 --- a/README.rst +++ b/README.rst @@ -22,7 +22,7 @@ * - Documentation - |GitHub Pages status| * - Code Style - - |Test style: pytest| |Code style: black| |Imports: isort| |Docstring style: google| + - |Test style: pytest| |Code style: ruff| |Imports: isort| |Docstring style: google| * - Linting - |pre-commit enabled| |Docstring formatter: docformatter| |Type Checker: pyright| |Linter: pylint| |Linter: Ruff| @@ -74,8 +74,8 @@ .. |PyPI: Downloads| image:: https://pepy.tech/badge/tm-devices :target: https://pepy.tech/project/tm_devices -.. |Code style: black| image:: https://img.shields.io/badge/code%20style-black-black - :target: https://github.com/psf/black +.. |Code style: ruff| image:: https://img.shields.io/badge/code%20style-ruff-black + :target: https://docs.astral.sh/ruff/formatter/ .. |Imports: isort| image:: https://img.shields.io/badge/imports-isort-black :target: https://pycqa.github.io/isort/ diff --git a/docs/conf.py b/docs/conf.py index 54133f48..412080c4 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -211,8 +211,7 @@ def skip_member( if ( what == "module" # pylint: disable=too-many-boolean-expressions or ( - what == "package" - and obj.short_name not in _package_set # pyright: ignore [reportUnknownMemberType] + what == "package" and obj.short_name not in _package_set # pyright: ignore [reportUnknownMemberType] ) or f"{os.path.sep}commands{os.path.sep}" in obj.pathname or obj.pathname.endswith(f"{os.path.sep}commands") diff --git a/examples/miscellaneous/custom_device_driver_support.py b/examples/miscellaneous/custom_device_driver_support.py index d629900c..7ac9ad55 100644 --- a/examples/miscellaneous/custom_device_driver_support.py +++ b/examples/miscellaneous/custom_device_driver_support.py @@ -25,9 +25,7 @@ def custom_method(self, value: str) -> None: # Add a scope that is currently supported by the package mso5: MSO5 = device_manager.add_scope("192.168.0.1") # pyright: ignore[reportGeneralTypeIssues] # Add the custom scope - custom_scope: CustomScope = device_manager.add_scope( - "192.168.0.2" - ) # pyright: ignore[reportGeneralTypeIssues] + custom_scope: CustomScope = device_manager.add_scope("192.168.0.2") # pyright: ignore[reportGeneralTypeIssues] # Custom drivers inherit all methods custom_scope.expect_esr(0) # check for no errors diff --git a/examples/scopes/tekscope_70k/dpojet/adding_dpojet_measurements.py b/examples/scopes/tekscope_70k/dpojet/adding_dpojet_measurements.py index 75dca12b..299be611 100644 --- a/examples/scopes/tekscope_70k/dpojet/adding_dpojet_measurements.py +++ b/examples/scopes/tekscope_70k/dpojet/adding_dpojet_measurements.py @@ -12,9 +12,7 @@ device_manager.visa_library = PYVISA_PY_BACKEND # Creating one 7K/70K/SX Scope driver object by providing ip address. - scope: MSO70KDX = device_manager.add_scope( - "127.0.0.1" - ) # pyright: ignore[reportGeneralTypeIssues] + scope: MSO70KDX = device_manager.add_scope("127.0.0.1") # pyright: ignore[reportGeneralTypeIssues] # Starting DPOJET scope.commands.dpojet.activate.write() diff --git a/examples/source_measure_units/2400/smu_2400_load_script_and_run.py b/examples/source_measure_units/2400/smu_2400_load_script_and_run.py index aa97f43c..1f5ab720 100644 --- a/examples/source_measure_units/2400/smu_2400_load_script_and_run.py +++ b/examples/source_measure_units/2400/smu_2400_load_script_and_run.py @@ -20,9 +20,7 @@ # Main code starts here with instantiation of the device manager and the SMU instrument connection. devmgr = DeviceManager(verbose=True) -smu2400: SMU2450 = devmgr.add_smu( - "192.168.0.1", alias="my2450" -) # pyright: ignore[reportGeneralTypeIssues] +smu2400: SMU2450 = devmgr.add_smu("192.168.0.1", alias="my2450") # pyright: ignore[reportGeneralTypeIssues] smu2400.enable_verification = False # Capture the path to the script file and load it to working memory. diff --git a/examples/source_measure_units/2400/smu_2450_leakage_current.py b/examples/source_measure_units/2400/smu_2450_leakage_current.py index 4f3c2643..9a1a1ec7 100644 --- a/examples/source_measure_units/2400/smu_2450_leakage_current.py +++ b/examples/source_measure_units/2400/smu_2450_leakage_current.py @@ -13,9 +13,7 @@ from tm_devices.drivers import SMU2450 with DeviceManager(verbose=False) as device_manager: - inst: SMU2450 = device_manager.add_smu( - "192.168.1.4", alias="my2450" - ) # pyright: ignore[reportGeneralTypeIssues] + inst: SMU2450 = device_manager.add_smu("192.168.1.4", alias="my2450") # pyright: ignore[reportGeneralTypeIssues] # Reset the instrument, which also clears the buffer. inst.commands.reset() diff --git a/examples/source_measure_units/2400/smu_2450_measuring_lowr_devices.py b/examples/source_measure_units/2400/smu_2450_measuring_lowr_devices.py index 947582a2..778f9785 100644 --- a/examples/source_measure_units/2400/smu_2450_measuring_lowr_devices.py +++ b/examples/source_measure_units/2400/smu_2450_measuring_lowr_devices.py @@ -21,9 +21,7 @@ with DeviceManager() as device_manager: print(device_manager.get_available_devices()) - inst: SMU2450 = device_manager.add_smu( - "192.168.4.74", alias="my2450" - ) # pyright: ignore[reportGeneralTypeIssues] + inst: SMU2450 = device_manager.add_smu("192.168.4.74", alias="my2450") # pyright: ignore[reportGeneralTypeIssues] # Configure the Simple Loop trigger model template to make 100 readings. inst.commands.trigger.model.load_simple_loop(100) diff --git a/examples/source_measure_units/2400/smu_2450_rechargeable_battery.py b/examples/source_measure_units/2400/smu_2450_rechargeable_battery.py index 14259549..36715a04 100644 --- a/examples/source_measure_units/2400/smu_2450_rechargeable_battery.py +++ b/examples/source_measure_units/2400/smu_2450_rechargeable_battery.py @@ -19,9 +19,7 @@ with DeviceManager() as device_manager: print(device_manager.get_available_devices()) - inst: SMU2450 = device_manager.add_smu( - "192.168.4.74", alias="my2450" - ) # pyright: ignore[reportGeneralTypeIssues] + inst: SMU2450 = device_manager.add_smu("192.168.4.74", alias="my2450") # pyright: ignore[reportGeneralTypeIssues] # Clear the buffer. inst.commands.buffer_var["defbuffer1"].clear() diff --git a/examples/source_measure_units/2400/smu_2450_solar_cell.py b/examples/source_measure_units/2400/smu_2450_solar_cell.py index f27d855d..73bb247e 100644 --- a/examples/source_measure_units/2400/smu_2450_solar_cell.py +++ b/examples/source_measure_units/2400/smu_2450_solar_cell.py @@ -15,9 +15,7 @@ with DeviceManager() as device_manager: print(device_manager.get_available_devices()) - inst: SMU2450 = device_manager.add_smu( - "192.168.4.74", alias="my2450" - ) # pyright: ignore[reportGeneralTypeIssues] + inst: SMU2450 = device_manager.add_smu("192.168.4.74", alias="my2450") # pyright: ignore[reportGeneralTypeIssues] # Define the number of points in the sweep. POINTS = 56 diff --git a/examples/source_measure_units/2400/smu_2460_pulse_train.py b/examples/source_measure_units/2400/smu_2460_pulse_train.py index 5efeacdd..f218d6e1 100644 --- a/examples/source_measure_units/2400/smu_2460_pulse_train.py +++ b/examples/source_measure_units/2400/smu_2460_pulse_train.py @@ -78,7 +78,8 @@ inst.commands.trigger.model.setblock_trigger_block_wait(3, "trigger.EVENT_TIMER1") inst.commands.trigger.model.setblock_trigger_block_config_recall(4, "OutputList") inst.commands.trigger.model.setblock_trigger_block_delay_constant( - 5, MEASURE_DELAY # type: ignore + 5, + MEASURE_DELAY, # type: ignore ) inst.commands.trigger.model.setblock_trigger_block_measure_digitize(6) inst.commands.trigger.model.setblock_trigger_block_wait(7, "trigger.EVENT_TIMER2") diff --git a/examples/source_measure_units/2400/smu_2461_1kw_pulsing.py b/examples/source_measure_units/2400/smu_2461_1kw_pulsing.py index 2c6ac363..5110bb39 100644 --- a/examples/source_measure_units/2400/smu_2461_1kw_pulsing.py +++ b/examples/source_measure_units/2400/smu_2461_1kw_pulsing.py @@ -10,9 +10,7 @@ with DeviceManager() as device_manager: print(device_manager.get_available_devices()) - smu2461: SMU2461 = device_manager.add_smu( - "TCPIP::0.0.0.0::inst0::INSTR", alias="my2461" - ) # pyright: ignore[reportGeneralTypeIssues] + smu2461: SMU2461 = device_manager.add_smu("TCPIP::0.0.0.0::inst0::INSTR", alias="my2461") # pyright: ignore[reportGeneralTypeIssues] # Reset the instrument smu2461.commands.reset() diff --git a/examples/source_measure_units/2400/smu_2470_mosfet_leakage.py b/examples/source_measure_units/2400/smu_2470_mosfet_leakage.py index 92afb102..6a3422cf 100644 --- a/examples/source_measure_units/2400/smu_2470_mosfet_leakage.py +++ b/examples/source_measure_units/2400/smu_2470_mosfet_leakage.py @@ -10,9 +10,7 @@ from tm_devices.drivers import SMU2470 with DeviceManager(verbose=False) as device_manager: - smu2470: SMU2470 = device_manager.add_smu( - "TCPIP::0.0.0.0::inst0::INSTR", alias="my2470" - ) # pyright: ignore[reportGeneralTypeIssues] + smu2470: SMU2470 = device_manager.add_smu("TCPIP::0.0.0.0::inst0::INSTR", alias="my2470") # pyright: ignore[reportGeneralTypeIssues] # Reset the instrument, which also clears the buffer. smu2470.commands.reset() diff --git a/examples/source_measure_units/2600/reading_dynamic_buffers.py b/examples/source_measure_units/2600/reading_dynamic_buffers.py index f814dc51..ecf5c8c6 100644 --- a/examples/source_measure_units/2600/reading_dynamic_buffers.py +++ b/examples/source_measure_units/2600/reading_dynamic_buffers.py @@ -4,9 +4,7 @@ with DeviceManager() as device_manager: # Create a SMU and type hint it as a 2601B - smu: SMU2601B = device_manager.add_smu( - "192.168.0.1" - ) # pyright: ignore[reportGeneralTypeIssues] + smu: SMU2601B = device_manager.add_smu("192.168.0.1") # pyright: ignore[reportGeneralTypeIssues] # Create a buffer BUFFER_NAME = "mybuffer" diff --git a/pyproject.toml b/pyproject.toml index 59e4e669..46444608 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,15 +4,6 @@ requires = ["poetry-core>=1.0.0"] [tool] -[tool.bandit] -skips = [ - 'B101', # allow the use of raw asserts, we don't compile to optimized byte code - 'B404' # allow the use of the subprocess module -] - -[tool.black] -line-length = 100 - [tool.coverage.report] exclude_lines = [ "if TYPE_CHECKING:", @@ -38,9 +29,6 @@ recursive = true wrap-descriptions = 100 wrap-summaries = 0 -[tool.mypy] -mypy_path = "./src/" - [tool.poetry] authors = [ "Tektronix ", @@ -100,7 +88,6 @@ zeroconf = ">=0.54.0" # Development dependencies [tool.poetry.group.dev.dependencies] -black = ">=22.6.0" coverage = {extras = ["toml"], version = ">=7.2.2"} docformatter = {extras = ["tomli"], version = ">=1.6.5,<1.7.1"} # upper bound is due to https://github.com/PyCQA/docformatter/issues/174 flask = ">=2.2.2" @@ -123,7 +110,7 @@ pytest-html = ">=4.0" pytest-order = ">=1.0.1" pytest-profiling = ">=1.7.0" python-semantic-release = ">=8.0" -ruff = ">=0.1.4" +ruff = ">=0.1.7" safety = ">=2.1.1" sphinx-autoapi = ">=2.0.0" sphinx-copybutton = ">=0.5.1" @@ -288,6 +275,7 @@ ignore = [ "FA100", # Missing `from __future__ import annotations`, but uses ... # TODO: enable this later "FBT", # flake8-boolean-trap "FIX002", # Line contains TODO + "ISC001", # single-line-implicit-string-concatenation (handled by formatter) "PGH003", # Use specific rule codes when ignoring type issues # TODO: enable this later "PTH", # flake8-use-pathlib # TODO: enable this later "PYI021", # Docstrings should not be included in stubs @@ -416,13 +404,13 @@ deps = setenv = DOC_PYTHON_VERSION = python3.11 # Keep this in sync with .readthedocs.yml and any CI scripts # Skip pre-commit checks that are explicitly performed by tox - SKIP = black,docformatter,ruff,pylint,pyright,pyright-verifytypes,pyroma + SKIP = ruff-format,docformatter,ruff,pylint,pyright,pyright-verifytypes,pyroma PYRIGHT_PYTHON_GLOBAL_NODE = False # This will cause python-pyright to use nodeenv to install node rather than use the system node commands_pre = poetry install --no-root commands = !tests: safety check - !tests: black --check --diff --color . + !tests: ruff format --check --diff . !tests: docformatter --check --diff . !tests: ruff check . !tests: pylint --report=y . diff --git a/src/tm_devices/commands/_smu2601b_commands.py b/src/tm_devices/commands/_smu2601b_commands.py index 5e5d3952..86f727fd 100644 --- a/src/tm_devices/commands/_smu2601b_commands.py +++ b/src/tm_devices/commands/_smu2601b_commands.py @@ -2029,7 +2029,9 @@ def pulse_i_measure_v( f"PulseIMeasureV({smu}, {bias}, {level}, {ton}, {toff}, {points})" ) except AttributeError as error: - msg = "No TSPDevice object was provided, unable to run the ``PulseIMeasureV()`` function." # noqa: E501 + msg = ( + "No TSPDevice object was provided, unable to run the ``PulseIMeasureV()`` function." + ) raise NoDeviceProvidedError(msg) from error def pulse_v_measure_i( @@ -2063,7 +2065,9 @@ def pulse_v_measure_i( f"PulseVMeasureI({smu}, {bias}, {level}, {ton}, {toff}, {points})" ) except AttributeError as error: - msg = "No TSPDevice object was provided, unable to run the ``PulseVMeasureI()`` function." # noqa: E501 + msg = ( + "No TSPDevice object was provided, unable to run the ``PulseVMeasureI()`` function." + ) raise NoDeviceProvidedError(msg) from error def query_pulse_config(self, tag: int) -> str: diff --git a/src/tm_devices/commands/_smu2602b_commands.py b/src/tm_devices/commands/_smu2602b_commands.py index 10eb20fd..1a807823 100644 --- a/src/tm_devices/commands/_smu2602b_commands.py +++ b/src/tm_devices/commands/_smu2602b_commands.py @@ -2135,7 +2135,9 @@ def pulse_i_measure_v( f"PulseIMeasureV({smu}, {bias}, {level}, {ton}, {toff}, {points})" ) except AttributeError as error: - msg = "No TSPDevice object was provided, unable to run the ``PulseIMeasureV()`` function." # noqa: E501 + msg = ( + "No TSPDevice object was provided, unable to run the ``PulseIMeasureV()`` function." + ) raise NoDeviceProvidedError(msg) from error def pulse_v_measure_i( @@ -2169,7 +2171,9 @@ def pulse_v_measure_i( f"PulseVMeasureI({smu}, {bias}, {level}, {ton}, {toff}, {points})" ) except AttributeError as error: - msg = "No TSPDevice object was provided, unable to run the ``PulseVMeasureI()`` function." # noqa: E501 + msg = ( + "No TSPDevice object was provided, unable to run the ``PulseVMeasureI()`` function." + ) raise NoDeviceProvidedError(msg) from error def query_pulse_config(self, tag: int) -> str: diff --git a/src/tm_devices/commands/_smu2604b_commands.py b/src/tm_devices/commands/_smu2604b_commands.py index e4a360ad..0554ac10 100644 --- a/src/tm_devices/commands/_smu2604b_commands.py +++ b/src/tm_devices/commands/_smu2604b_commands.py @@ -1917,7 +1917,9 @@ def pulse_i_measure_v( f"PulseIMeasureV({smu}, {bias}, {level}, {ton}, {toff}, {points})" ) except AttributeError as error: - msg = "No TSPDevice object was provided, unable to run the ``PulseIMeasureV()`` function." # noqa: E501 + msg = ( + "No TSPDevice object was provided, unable to run the ``PulseIMeasureV()`` function." + ) raise NoDeviceProvidedError(msg) from error def pulse_v_measure_i( @@ -1951,7 +1953,9 @@ def pulse_v_measure_i( f"PulseVMeasureI({smu}, {bias}, {level}, {ton}, {toff}, {points})" ) except AttributeError as error: - msg = "No TSPDevice object was provided, unable to run the ``PulseVMeasureI()`` function." # noqa: E501 + msg = ( + "No TSPDevice object was provided, unable to run the ``PulseVMeasureI()`` function." + ) raise NoDeviceProvidedError(msg) from error def query_pulse_config(self, tag: int) -> str: diff --git a/src/tm_devices/commands/_smu2606b_commands.py b/src/tm_devices/commands/_smu2606b_commands.py index 4cf33597..b54036c9 100644 --- a/src/tm_devices/commands/_smu2606b_commands.py +++ b/src/tm_devices/commands/_smu2606b_commands.py @@ -2102,7 +2102,9 @@ def pulse_i_measure_v( f"PulseIMeasureV({smu}, {bias}, {level}, {ton}, {toff}, {points})" ) except AttributeError as error: - msg = "No TSPDevice object was provided, unable to run the ``PulseIMeasureV()`` function." # noqa: E501 + msg = ( + "No TSPDevice object was provided, unable to run the ``PulseIMeasureV()`` function." + ) raise NoDeviceProvidedError(msg) from error def pulse_v_measure_i( @@ -2136,7 +2138,9 @@ def pulse_v_measure_i( f"PulseVMeasureI({smu}, {bias}, {level}, {ton}, {toff}, {points})" ) except AttributeError as error: - msg = "No TSPDevice object was provided, unable to run the ``PulseVMeasureI()`` function." # noqa: E501 + msg = ( + "No TSPDevice object was provided, unable to run the ``PulseVMeasureI()`` function." + ) raise NoDeviceProvidedError(msg) from error def query_pulse_config(self, tag: int) -> str: diff --git a/src/tm_devices/commands/_smu2611b_commands.py b/src/tm_devices/commands/_smu2611b_commands.py index 08dc63f6..566edec2 100644 --- a/src/tm_devices/commands/_smu2611b_commands.py +++ b/src/tm_devices/commands/_smu2611b_commands.py @@ -2026,7 +2026,9 @@ def pulse_i_measure_v( f"PulseIMeasureV({smu}, {bias}, {level}, {ton}, {toff}, {points})" ) except AttributeError as error: - msg = "No TSPDevice object was provided, unable to run the ``PulseIMeasureV()`` function." # noqa: E501 + msg = ( + "No TSPDevice object was provided, unable to run the ``PulseIMeasureV()`` function." + ) raise NoDeviceProvidedError(msg) from error def pulse_v_measure_i( @@ -2060,7 +2062,9 @@ def pulse_v_measure_i( f"PulseVMeasureI({smu}, {bias}, {level}, {ton}, {toff}, {points})" ) except AttributeError as error: - msg = "No TSPDevice object was provided, unable to run the ``PulseVMeasureI()`` function." # noqa: E501 + msg = ( + "No TSPDevice object was provided, unable to run the ``PulseVMeasureI()`` function." + ) raise NoDeviceProvidedError(msg) from error def query_pulse_config(self, tag: int) -> str: diff --git a/src/tm_devices/commands/_smu2612b_commands.py b/src/tm_devices/commands/_smu2612b_commands.py index a320492d..ea0c2559 100644 --- a/src/tm_devices/commands/_smu2612b_commands.py +++ b/src/tm_devices/commands/_smu2612b_commands.py @@ -2132,7 +2132,9 @@ def pulse_i_measure_v( f"PulseIMeasureV({smu}, {bias}, {level}, {ton}, {toff}, {points})" ) except AttributeError as error: - msg = "No TSPDevice object was provided, unable to run the ``PulseIMeasureV()`` function." # noqa: E501 + msg = ( + "No TSPDevice object was provided, unable to run the ``PulseIMeasureV()`` function." + ) raise NoDeviceProvidedError(msg) from error def pulse_v_measure_i( @@ -2166,7 +2168,9 @@ def pulse_v_measure_i( f"PulseVMeasureI({smu}, {bias}, {level}, {ton}, {toff}, {points})" ) except AttributeError as error: - msg = "No TSPDevice object was provided, unable to run the ``PulseVMeasureI()`` function." # noqa: E501 + msg = ( + "No TSPDevice object was provided, unable to run the ``PulseVMeasureI()`` function." + ) raise NoDeviceProvidedError(msg) from error def query_pulse_config(self, tag: int) -> str: diff --git a/src/tm_devices/commands/_smu2614b_commands.py b/src/tm_devices/commands/_smu2614b_commands.py index e06b2320..68d63638 100644 --- a/src/tm_devices/commands/_smu2614b_commands.py +++ b/src/tm_devices/commands/_smu2614b_commands.py @@ -1914,7 +1914,9 @@ def pulse_i_measure_v( f"PulseIMeasureV({smu}, {bias}, {level}, {ton}, {toff}, {points})" ) except AttributeError as error: - msg = "No TSPDevice object was provided, unable to run the ``PulseIMeasureV()`` function." # noqa: E501 + msg = ( + "No TSPDevice object was provided, unable to run the ``PulseIMeasureV()`` function." + ) raise NoDeviceProvidedError(msg) from error def pulse_v_measure_i( @@ -1948,7 +1950,9 @@ def pulse_v_measure_i( f"PulseVMeasureI({smu}, {bias}, {level}, {ton}, {toff}, {points})" ) except AttributeError as error: - msg = "No TSPDevice object was provided, unable to run the ``PulseVMeasureI()`` function." # noqa: E501 + msg = ( + "No TSPDevice object was provided, unable to run the ``PulseVMeasureI()`` function." + ) raise NoDeviceProvidedError(msg) from error def query_pulse_config(self, tag: int) -> str: diff --git a/src/tm_devices/commands/_smu2634b_commands.py b/src/tm_devices/commands/_smu2634b_commands.py index 8ca1baa1..86a5c2b0 100644 --- a/src/tm_devices/commands/_smu2634b_commands.py +++ b/src/tm_devices/commands/_smu2634b_commands.py @@ -1916,7 +1916,9 @@ def pulse_i_measure_v( f"PulseIMeasureV({smu}, {bias}, {level}, {ton}, {toff}, {points})" ) except AttributeError as error: - msg = "No TSPDevice object was provided, unable to run the ``PulseIMeasureV()`` function." # noqa: E501 + msg = ( + "No TSPDevice object was provided, unable to run the ``PulseIMeasureV()`` function." + ) raise NoDeviceProvidedError(msg) from error def pulse_v_measure_i( @@ -1950,7 +1952,9 @@ def pulse_v_measure_i( f"PulseVMeasureI({smu}, {bias}, {level}, {ton}, {toff}, {points})" ) except AttributeError as error: - msg = "No TSPDevice object was provided, unable to run the ``PulseVMeasureI()`` function." # noqa: E501 + msg = ( + "No TSPDevice object was provided, unable to run the ``PulseVMeasureI()`` function." + ) raise NoDeviceProvidedError(msg) from error def query_pulse_config(self, tag: int) -> str: diff --git a/src/tm_devices/commands/_smu2635b_commands.py b/src/tm_devices/commands/_smu2635b_commands.py index 6e453578..6c68ae75 100644 --- a/src/tm_devices/commands/_smu2635b_commands.py +++ b/src/tm_devices/commands/_smu2635b_commands.py @@ -2028,7 +2028,9 @@ def pulse_i_measure_v( f"PulseIMeasureV({smu}, {bias}, {level}, {ton}, {toff}, {points})" ) except AttributeError as error: - msg = "No TSPDevice object was provided, unable to run the ``PulseIMeasureV()`` function." # noqa: E501 + msg = ( + "No TSPDevice object was provided, unable to run the ``PulseIMeasureV()`` function." + ) raise NoDeviceProvidedError(msg) from error def pulse_v_measure_i( @@ -2062,7 +2064,9 @@ def pulse_v_measure_i( f"PulseVMeasureI({smu}, {bias}, {level}, {ton}, {toff}, {points})" ) except AttributeError as error: - msg = "No TSPDevice object was provided, unable to run the ``PulseVMeasureI()`` function." # noqa: E501 + msg = ( + "No TSPDevice object was provided, unable to run the ``PulseVMeasureI()`` function." + ) raise NoDeviceProvidedError(msg) from error def query_pulse_config(self, tag: int) -> str: diff --git a/src/tm_devices/commands/_smu2636b_commands.py b/src/tm_devices/commands/_smu2636b_commands.py index d151b82f..946608dd 100644 --- a/src/tm_devices/commands/_smu2636b_commands.py +++ b/src/tm_devices/commands/_smu2636b_commands.py @@ -2134,7 +2134,9 @@ def pulse_i_measure_v( f"PulseIMeasureV({smu}, {bias}, {level}, {ton}, {toff}, {points})" ) except AttributeError as error: - msg = "No TSPDevice object was provided, unable to run the ``PulseIMeasureV()`` function." # noqa: E501 + msg = ( + "No TSPDevice object was provided, unable to run the ``PulseIMeasureV()`` function." + ) raise NoDeviceProvidedError(msg) from error def pulse_v_measure_i( @@ -2168,7 +2170,9 @@ def pulse_v_measure_i( f"PulseVMeasureI({smu}, {bias}, {level}, {ton}, {toff}, {points})" ) except AttributeError as error: - msg = "No TSPDevice object was provided, unable to run the ``PulseVMeasureI()`` function." # noqa: E501 + msg = ( + "No TSPDevice object was provided, unable to run the ``PulseVMeasureI()`` function." + ) raise NoDeviceProvidedError(msg) from error def query_pulse_config(self, tag: int) -> str: diff --git a/src/tm_devices/commands/_smu2651a_commands.py b/src/tm_devices/commands/_smu2651a_commands.py index cef8cbe1..9de55724 100644 --- a/src/tm_devices/commands/_smu2651a_commands.py +++ b/src/tm_devices/commands/_smu2651a_commands.py @@ -2064,7 +2064,9 @@ def pulse_i_measure_v( f"PulseIMeasureV({smu}, {bias}, {level}, {ton}, {toff}, {points})" ) except AttributeError as error: - msg = "No TSPDevice object was provided, unable to run the ``PulseIMeasureV()`` function." # noqa: E501 + msg = ( + "No TSPDevice object was provided, unable to run the ``PulseIMeasureV()`` function." + ) raise NoDeviceProvidedError(msg) from error def pulse_v_measure_i( @@ -2098,7 +2100,9 @@ def pulse_v_measure_i( f"PulseVMeasureI({smu}, {bias}, {level}, {ton}, {toff}, {points})" ) except AttributeError as error: - msg = "No TSPDevice object was provided, unable to run the ``PulseVMeasureI()`` function." # noqa: E501 + msg = ( + "No TSPDevice object was provided, unable to run the ``PulseVMeasureI()`` function." + ) raise NoDeviceProvidedError(msg) from error def query_pulse_config(self, tag: int) -> str: diff --git a/src/tm_devices/commands/_smu2657a_commands.py b/src/tm_devices/commands/_smu2657a_commands.py index 53e082e4..ef0f08f6 100644 --- a/src/tm_devices/commands/_smu2657a_commands.py +++ b/src/tm_devices/commands/_smu2657a_commands.py @@ -2063,7 +2063,9 @@ def pulse_i_measure_v( f"PulseIMeasureV({smu}, {bias}, {level}, {ton}, {toff}, {points})" ) except AttributeError as error: - msg = "No TSPDevice object was provided, unable to run the ``PulseIMeasureV()`` function." # noqa: E501 + msg = ( + "No TSPDevice object was provided, unable to run the ``PulseIMeasureV()`` function." + ) raise NoDeviceProvidedError(msg) from error def pulse_v_measure_i( @@ -2097,7 +2099,9 @@ def pulse_v_measure_i( f"PulseVMeasureI({smu}, {bias}, {level}, {ton}, {toff}, {points})" ) except AttributeError as error: - msg = "No TSPDevice object was provided, unable to run the ``PulseVMeasureI()`` function." # noqa: E501 + msg = ( + "No TSPDevice object was provided, unable to run the ``PulseVMeasureI()`` function." + ) raise NoDeviceProvidedError(msg) from error def query_pulse_config(self, tag: int) -> str: diff --git a/src/tm_devices/components/dm_config_parser.py b/src/tm_devices/components/dm_config_parser.py index 377e213f..c3376955 100644 --- a/src/tm_devices/components/dm_config_parser.py +++ b/src/tm_devices/components/dm_config_parser.py @@ -356,7 +356,7 @@ def __parse_env_devices(self) -> List[Dict[str, Any]]: @staticmethod def __parse_config_file( - config_file_path: Union[str, os.PathLike[str]] + config_file_path: Union[str, os.PathLike[str]], ) -> Tuple[DMConfigOptions, List[Dict[str, Any]]]: """Parse config file for the options flags and list of device configuration dictionaries. diff --git a/src/tm_devices/drivers/pi/pi_device.py b/src/tm_devices/drivers/pi/pi_device.py index 705ad38f..5d844662 100644 --- a/src/tm_devices/drivers/pi/pi_device.py +++ b/src/tm_devices/drivers/pi/pi_device.py @@ -281,13 +281,15 @@ def device_clear(self) -> None: # pragma: no cover def disable_srq_events(self) -> None: # pragma: no cover """Disable the service request event for the device.""" self._visa_resource.disable_event( - visa_constants.VI_EVENT_SERVICE_REQ, visa_constants.VI_QUEUE # type: ignore + visa_constants.VI_EVENT_SERVICE_REQ, # type: ignore + visa_constants.VI_QUEUE, # type: ignore ) def enable_srq_events(self) -> None: # pragma: no cover """Enable the service request event for the device.""" self._visa_resource.enable_event( - visa_constants.VI_EVENT_SERVICE_REQ, visa_constants.VI_QUEUE # type: ignore + visa_constants.VI_EVENT_SERVICE_REQ, # type: ignore + visa_constants.VI_QUEUE, # type: ignore ) def get_visa_stb(self) -> int: # pragma: no cover diff --git a/tests/conftest.py b/tests/conftest.py index f918d280..5b86e5c4 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -79,9 +79,7 @@ def fixture_device_manager() -> Generator[DeviceManager, None, None]: ), mock.patch( "pyvisa.resources.messagebased.MessageBasedResource.clear", mock.MagicMock(return_value=pyvisa.constants.StatusCode.success), - ), DeviceManager( - verbose=True - ) as dev_manager: + ), DeviceManager(verbose=True) as dev_manager: dev_manager.visa_library = SIMULATED_VISA_LIB yield dev_manager diff --git a/tests/requirements.txt b/tests/requirements.txt index 4ccf5dca..53039fa9 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,8 +1,7 @@ -black coverage[toml]>=7.2.2 http_server_mock pytest-cov pytest-html pytest-order pytest-profiling -ruff>=0.0.267 +ruff>=0.1.7 diff --git a/tests/test_device_manager.py b/tests/test_device_manager.py index d90370b5..78c8b80a 100644 --- a/tests/test_device_manager.py +++ b/tests/test_device_manager.py @@ -353,7 +353,8 @@ def custom_model_getter_afg3kc(device: AFG3KC, value: str) -> str: [ # noqa: S603 sys.executable, "-m", - "black", + "ruff", + "format", "--quiet", os.path.basename(generated_stub_file), ] diff --git a/tests/test_rest_api_device.py b/tests/test_rest_api_device.py index e61f9b33..5fa1c433 100644 --- a/tests/test_rest_api_device.py +++ b/tests/test_rest_api_device.py @@ -160,7 +160,8 @@ def test_unsupported_request_type(rest_api_device: CustomRestApiDevice) -> None: """ with pytest.raises(ValueError, match="UNSUPPORTED is an unsupported request type."): rest_api_device._send_request( # noqa: SLF001 - request_type="UNSUPPORTED", url="/api" # type: ignore + request_type="UNSUPPORTED", # type: ignore + url="/api", )