Peter Barker
76a39dc4df
Tools: fix flake8 B008 errors, methods-in-function-definitions
...
e.g.
./Tools/scripts/param_check_all.py:180:40: B008 Do not perform function calls in argument defaults. The call is performed only once at function definition time. All calls to your function will reuse the result of that definition-time function call. If this is intended, assign the function call to a module-level variable and use that variable as a default value.
2025-10-27 11:18:20 +11:00
Christian Clauss
123c2efc44
Tools: Fix pytest DeprecationWarning: 'maxsplit' is passed as positional argument
...
```diff
- parts = re.split(r'[,=\s]+', processed_line, 1)
+ parts = re.split(r'[,=\s]+', processed_line, maxsplit=1)
```
Pytest: `DeprecationWarning: 'maxsplit' is passed as positional argument`
* https://docs.python.org/3/library/re.html#re.split
### How was this tested?
Localhost testing...
% `python -m pytest --ignore=Tools/ros2`
```
========================================== test session starts ==========================================
platform darwin -- Python 3.13.5, pytest-8.4.1, pluggy-1.6.0
rootdir: /Users/cclauss/Python/ardupilot
configfile: pyproject.toml
collected 53 items
Tools/autotest/unittest/annotate_params_test.py ........................ [ 45%]
Tools/autotest/unittest/extract_param_defaults_test.py .................. [ 79%]
Tools/scripts/param_check_test.py ........... [100%]
========================================== warnings summary ==========================================
Tools/scripts/param_check_test.py: 118 warnings
/Users/cclauss/Python/ardupilot/Tools/scripts/param_check.py:338: DeprecationWarning: 'maxsplit' is passed as positional argument
parts = re.split(r'[,=\s]+', processed_line, 1)
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
========================================== 53 passed, 118 warnings in 2.74s ==========================================
```
After this change:
% `python -m pytest --ignore=Tools/ros2`
```
========================================== test session starts ==========================================
platform darwin -- Python 3.13.5, pytest-8.4.1, pluggy-1.6.0
rootdir: /Users/cclauss/Python/ardupilot
configfile: pyproject.toml
collected 53 items
Tools/autotest/unittest/annotate_params_test.py ........................ [ 45%]
Tools/autotest/unittest/extract_param_defaults_test.py .................. [ 79%]
Tools/scripts/param_check_test.py ........... [100%]
========================================== 53 passed in 2.55s ==========================================
```
Also failed with `ruff check --select=B034` and passed after the proposed change.
https://docs.astral.sh/ruff/rules/re-sub-positional-args
2025-07-07 13:10:44 +10:00