rdmorganiser / rdmo

A tool to support the planning, implementation, and organization of research data management.
https://rdmorganiser.github.io
Apache License 2.0
105 stars 49 forks source link

chore: enable flake8-pytest-style (pt) rule in ruff config #1053

Closed afuetterer closed 4 months ago

afuetterer commented 4 months ago

Description

Fixes #1052

This PR enables the flake8-pytest-style (PT) ruff rule as suggested in the linked issue. All violations are fixed as well in this PR.

At the moment this settings needs to be set to false:

[tool.ruff.lint.flake8-pytest-style]
fixture-parentheses = false

to allow fixtures without parantheses

pytest.fixture instead of pytest.fixture(). It will default to true in the future, according the ruff docs.

[tool.ruff.lint.flake8-pytest-style]
parametrize-names-type = "csv"

needs to be set to csv to allow for parametrization in tests like

pytest.mark.parametrize('username,password', users) instead of pytest.mark.parametrize(('username,password'), users)

flake8-pytest-style suggests using tuples.

What do you think?

Types of Changes

Checklist

afuetterer commented 4 months ago

No, I don't know why. I guess to make it consistent with multiple parametrizations, i.e. group stuff from the same groups into tuples? The differentiate between "csv", "tuple" and "list".

I know, the very first examples when using pytest do like this ("csv" style): pytest.mark.parametrize('username,password', users)

So, keep it like this?

jochenklar commented 4 months ago

Yes please keep csv style.

afuetterer commented 4 months ago

Alright, going to merge. This means a rebase is needed for @MyPyDavid in #1039.