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

Fix the warning of ruff #18

Open
d-krupke opened this issue Dec 31, 2023 · 1 comment
Open

Fix the warning of ruff #18

d-krupke opened this issue Dec 31, 2023 · 1 comment
Labels
good first issue Good for newcomers

Comments

@d-krupke
Copy link
Owner

This is a pretty simple task. Ruff finds some anti-patterns in the code that should be updated. Most of the time, it directly gives hints. You can run Ruff with pre-commit yourself via pre-commit run --all-files.

Here is a log from my computer:

ruff.....................................................................Failed
- hook id: ruff
- exit code: 1

docs/conf.py:9:20: PTH100 `os.path.abspath()` should be replaced by `Path.resolve()`
examples/example_1.py:11:10: PTH123 `open()` should be replaced by `Path.open()`
examples/example_1.py:12:9: T201 `print` found
examples/example_2.py:14:5: T201 `print` found
examples/example_2.py:15:10: PTH123 `open()` should be replaced by `Path.open()`
examples/example_2b.py:6:5: T201 `print` found
examples/example_2b.py:7:5: T201 `print` found
examples/example_3.py:10:5: T201 `print` found
examples/example_3.py:15:5: T201 `print` found
examples/example_3.py:20:5: T201 `print` found
src/slurminade/batch.py:83:21: PLW2901 `for` loop variable `tasks` overwritten by assignment target
src/slurminade/batch.py:137:13: T201 `print` found
src/slurminade/conf.py:17:12: PTH113 `os.path.isfile()` should be replaced by `Path.is_file()`
src/slurminade/conf.py:18:18: PTH123 `open()` should be replaced by `Path.open()`
src/slurminade/conf.py:23:9: T201 `print` found
src/slurminade/conf.py:35:12: PTH118 `os.path.join()` should be replaced by `Path` with `/` operator
src/slurminade/conf.py:38:16: PTH118 `os.path.join()` should be replaced by `Path` with `/` operator
src/slurminade/dispatcher.py:168:53: ARG002 Unused method argument: `options`
src/slurminade/dispatcher.py:183:12: PTH110 `os.path.exists()` should be replaced by `Path.exists()`
src/slurminade/dispatcher.py:184:13: PTH107 `os.remove()` should be replaced by `Path.unlink()`
src/slurminade/dispatcher.py:189:9: ARG002 Unused method argument: `conf`
src/slurminade/dispatcher.py:190:9: ARG002 Unused method argument: `simple_slurm_kwargs`
src/slurminade/dispatcher.py:194:9: T201 `print` found
src/slurminade/dispatcher.py:199:9: ARG002 Unused method argument: `conf`
src/slurminade/dispatcher.py:200:9: ARG002 Unused method argument: `simple_slurm_kwargs`
src/slurminade/dispatcher.py:204:9: T201 `print` found
src/slurminade/dispatcher.py:225:16: RET504 Unnecessary variable assignment before `return` statement
src/slurminade/dispatcher.py:231:9: RET505 Unnecessary `else` after `return` statement
src/slurminade/dispatcher.py:260:9: RET505 Unnecessary `else` after `return` statement
src/slurminade/dispatcher.py:275:9: RET505 Unnecessary `else` after `return` statement
src/slurminade/dispatcher.py:293:53: ARG002 Unused method argument: `options`
src/slurminade/dispatcher.py:303:9: ARG002 Unused method argument: `conf`
src/slurminade/dispatcher.py:304:9: ARG002 Unused method argument: `simple_slurm_kwargs`
src/slurminade/dispatcher.py:313:9: ARG002 Unused method argument: `conf`
src/slurminade/dispatcher.py:314:9: ARG002 Unused method argument: `simple_slurm_kwargs`
src/slurminade/dispatcher.py:330:53: ARG002 Unused method argument: `options`
src/slurminade/dispatcher.py:340:9: ARG002 Unused method argument: `conf`
src/slurminade/dispatcher.py:341:9: ARG002 Unused method argument: `simple_slurm_kwargs`
src/slurminade/dispatcher.py:349:9: ARG002 Unused method argument: `conf`
src/slurminade/dispatcher.py:350:9: ARG002 Unused method argument: `simple_slurm_kwargs`
src/slurminade/dispatcher.py:398:5: PLW0603 Using the global statement to update `__dispatcher` is discouraged
src/slurminade/dispatcher.py:401:13: PLW0603 Using the global statement to update `__dispatcher` is discouraged
src/slurminade/dispatcher.py:415:5: PLW0603 Using the global statement to update `__dispatcher` is discouraged
src/slurminade/execute.py:34:14: PTH123 `open()` should be replaced by `Path.open()`
src/slurminade/execute.py:51:10: PTH123 `open()` should be replaced by `Path.open()`
src/slurminade/execute.py:55:5: PLW0603 Using the global statement to update `__name__` is discouraged
src/slurminade/function.py:75:9: SIM108 Use ternary operator `job_ids = [job_ids] if isinstance(job_ids, int) else list(job_ids)` instead of `if`-`else`-block
src/slurminade/function.py:146:5: RET505 Unnecessary `else` after `return` statement
src/slurminade/function_map.py:42:33: PTH100 `os.path.abspath()` should be replaced by `Path.resolve()`
src/slurminade/function_map.py:104:12: PTH113 `os.path.isfile()` should be replaced by `Path.is_file()`
src/slurminade/function_map.py:107:19: PTH100 `os.path.abspath()` should be replaced by `Path.resolve()`
src/slurminade/guard.py:20:12: PLW0602 Using global for `_exec_flag` but no assignment is done
src/slurminade/guard.py:35:5: PLW0603 Using the global statement to update `_exec_flag` is discouraged
src/slurminade/guard.py:44:5: PLW0603 Using the global statement to update `_exec_flag` is discouraged
src/slurminade/options.py:14:17: PLW2901 `for` loop variable `v` overwritten by assignment target
tests/test_create_command.py:13:10: PTH123 `open()` should be replaced by `Path.open()`
tests/test_create_command.py:47:14: PTH123 `open()` should be replaced by `Path.open()`
tests/test_local.py:13:10: PTH123 `open()` should be replaced by `Path.open()`
tests/test_local.py:18:8: PTH110 `os.path.exists()` should be replaced by `Path.exists()`
tests/test_local.py:19:9: PTH107 `os.remove()` should be replaced by `Path.unlink()`
tests/test_local.py:24:10: PTH123 `open()` should be replaced by `Path.open()`
tests/test_local.py:29:8: PTH110 `os.path.exists()` should be replaced by `Path.exists()`
tests/test_local.py:30:9: PTH107 `os.remove()` should be replaced by `Path.unlink()`
tests/test_local.py:37:16: PTH110 `os.path.exists()` should be replaced by `Path.exists()`
tests/test_local.py:43:16: PTH110 `os.path.exists()` should be replaced by `Path.exists()`
tests/test_local.py:44:14: PTH123 `open()` should be replaced by `Path.open()`
tests/test_subprocess.py:12:10: PTH123 `open()` should be replaced by `Path.open()`
tests/test_subprocess.py:17:8: PTH110 `os.path.exists()` should be replaced by `Path.exists()`
tests/test_subprocess.py:18:9: PTH107 `os.remove()` should be replaced by `Path.unlink()`
tests/test_subprocess.py:23:10: PTH123 `open()` should be replaced by `Path.open()`
tests/test_subprocess.py:28:8: PTH110 `os.path.exists()` should be replaced by `Path.exists()`
tests/test_subprocess.py:29:9: PTH107 `os.remove()` should be replaced by `Path.unlink()`
tests/test_subprocess.py:35:12: PTH110 `os.path.exists()` should be replaced by `Path.exists()`
tests/test_subprocess.py:37:12: PTH100 `os.path.abspath()` should be replaced by `Path.resolve()`
tests/test_subprocess.py:48:16: PTH110 `os.path.exists()` should be replaced by `Path.exists()`
tests/test_subprocess.py:58:16: PTH110 `os.path.exists()` should be replaced by `Path.exists()`
tests/test_subprocess.py:59:14: PTH123 `open()` should be replaced by `Path.open()`
@d-krupke d-krupke added the good first issue Good for newcomers label Dec 31, 2023
@d-krupke
Copy link
Owner Author

src/slurminade/dispatcher.py:303:9: ARG002 Unused method argument: `conf`
src/slurminade/dispatcher.py:304:9: ARG002 Unused method argument: `simple_slurm_kwargs`
src/slurminade/dispatcher.py:313:9: ARG002 Unused method argument: `conf`
src/slurminade/dispatcher.py:314:9: ARG002 Unused method argument: `simple_slurm_kwargs`

should not be fixed but just an ignore flag should be added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant