Skip to content

Commit

Permalink
Switch from pylint and Black to ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberw committed Jan 18, 2024
1 parent 654ab55 commit 2962e47
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 15 deletions.
6 changes: 6 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"charliermarsh.ruff",
"ms-python.mypy-type-checker"
]
}
4 changes: 1 addition & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"python.formatting.provider": "black",
"files.exclude": {
"**/env": true,
"**/__pycache__": true,
Expand All @@ -12,14 +11,13 @@
"**/_version.py": true,
"**/.eggs": true
},
"python.linting.pylintEnabled": true,
"files.watcherExclude": {
"**/target": true
},
"editor.formatOnSave": true,
"[python]": {
"editor.formatOnPaste": false,
"editor.defaultFormatter": "ms-python.black-formatter"
"editor.defaultFormatter": "charliermarsh.ruff"
},
"python.languageServer": "Pylance",
"python.analysis.typeCheckingMode": "basic",
Expand Down
4 changes: 1 addition & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@ If you want to talk about a contribution before you start writing code & making

In order to maintain a good level of quality, please ensure that your code:

* Is formatted using black (https://github.com/psf/black)

* Passes linting with pylint (https://www.pylint.org/)
* Is formatted and linted using [ruff](https://docs.astral.sh/ruff/)
8 changes: 4 additions & 4 deletions locust_swarm/swarm.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
try:
import svs_locust # pylint: disable=import-outside-toplevel
import svs_locust
except ModuleNotFoundError:
# svs-locust is a library that is only used internally at Svenska Spel, please ignore it
# We need to import it here to get some variables and the path to the installed package
Expand Down Expand Up @@ -190,7 +190,7 @@ def check_output_multiple(list_of_commands):
for process in running_procs:
retcode = process.poll()
if retcode is not None: # Process finished.
running_procs.remove(process) # pylint: disable=modified-iterating-list
running_procs.remove(process)
if retcode != 0:
raise Exception(f"Bad return code {retcode} from command: {process.args}")
break
Expand Down Expand Up @@ -371,7 +371,7 @@ def main():
locustfile = args.locustfile or "locustfile.py"

if "/" in locustfile:
parser.error( # pylint: disable=not-callable
parser.error(
"Locustfile (-f) must be a file in the current directory (I'm lazy and havent fixed support for this yet)"
)

Expand Down Expand Up @@ -523,7 +523,7 @@ def get_available_servers_and_lock_them():
if max_run_time + args.exit_timeout < time.time() - start_time:
logging.error(
f"Locust exceeded the run time specified ({max_run_time}) by more than 30 seconds, giving up"
) # pylint: disable=raise-missing-from
)
master_proc.send_signal(1)
except KeyboardInterrupt:
pass
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[tool.black]
[tool.ruff]
line-length = 120
7 changes: 3 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ envlist = py{38,39,310,311}

[testenv]
deps =
black
pylint
ruff
locust-plugins # not strictly a requirement, but probably better to have it than not
commands =
pylint locust_swarm/
black --check locust_swarm/
ruff check
ruff format --check
swarm --help

0 comments on commit 2962e47

Please sign in to comment.