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

Refactor: Replace isort by ruff in pre-commit #2325

Merged
merged 6 commits into from
Feb 14, 2023

Conversation

tomaarsen
Copy link
Contributor

@tomaarsen tomaarsen commented Feb 9, 2023

Hello!

Pull Request overview

  • Replaced isort by ruff in pre-commit
    • This has fixed the import sorting throughout the repo.
  • Manually went through ruff errors and fixed a bunch:
    • Unused imports
    • Added if TYPE_CHECKING: statements
    • Placed # noqa: <errcode> where the warned-about statement is the desired behaviour
  • Add basic ruff configuration to pyproject.toml

Details

This PR focuses on replacing isort by ruff in pre-commit. The motivation for this is that:

  • isort frequently breaks. I have experienced 2 separate occasions in the last few months alone where the latest isort release has broken my CI runs in NLTK and SetFit.
  • isort is no longer supported for Python 3.7, whereas Argilla still supports 3.7 for now.
  • ruff is absurdly fast, I actually can't believe how quick it is.

This PR consists of 3 commits at this time, and I would advise looking at them commit-by-commit rather than at the PR as a whole. I'll also explain each commit individually.

Add ruff basic configuration

I've added basic configuration for ruff, a very efficient linter. I recommend the following commands:

# Get all [F]ailures and [E]rrors
ruff .

# See all import sort errors
ruff . --select I

# Fix all import sort errors
ruff . --select I --fix

Remove unused imports, apply some noqa's, add TYPE_CHECKING

The unused imports speaks for itself.

As for the noqa's, ruff (like most linters) respect the # noqa (no quality assurance) keyword. I've used the keyword in various locations where linters would warn, but the behaviour is actually correct. As a result, the output of ruff . now only points to questionable code.

Lastly, I added TYPE_CHECKING in some locations. If type hints hint at objects that do not need to be imported during run-time, then it's common to type hint like arr: "numpy.ndarray". However, IDE's won't understand what arr is. Python has implemented TYPE_CHECKING which can be used to conditionally import code only when type checking. As a result, the code block is not actually executed in practice, but the inclusion of it allows for IDEs to better support development.
See an example here:

from typing import TYPE_CHECKING

if TYPE_CHECKING:
    import numpy

def func(arr: "numpy.ndarray") -> None:
    ...

Replace isort with ruff in CI

I've replaced isort (which was both broken for 5.11.* and does not work for Python 3.8 in 5.12.*) with ruff in the CI, using both --select I to only select isort warnings and --fix to immediately fix the warnings.

Then I ran pre-commit run --all to fix the ~67 outstanding issues in the repository.


Type of change

  • Refactor (change restructuring the codebase without changing functionality)

How Has This Been Tested

I verified that the behaviour did not change using pytest tests.

Checklist

  • I have merged the original branch into my forked branch

  • I added relevant documentation

  • follows the style guidelines of this project

  • I did a self-review of my code

  • I added comments to my code

  • I made corresponding changes to the documentation

  • My changes generate no new warnings

  • I have added tests that prove my fix is effective or that my feature works

  • Tom Aarsen

@tomaarsen tomaarsen added the area: ci Indicates that an issue or pull request is related to the Continuous Integration (CI) label Feb 9, 2023
@codecov
Copy link

codecov bot commented Feb 9, 2023

Codecov Report

Base: 91.84% // Head: 91.86% // Increases project coverage by +0.02% 🎉

Coverage data is based on head (e636187) compared to base (ff4e79f).
Patch coverage: 88.23% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2325      +/-   ##
===========================================
+ Coverage    91.84%   91.86%   +0.02%     
===========================================
  Files          161      161              
  Lines         7910     7895      -15     
===========================================
- Hits          7265     7253      -12     
+ Misses         645      642       -3     
Flag Coverage Δ
pytest 91.86% <88.23%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/argilla/__init__.py 100.00% <ø> (ø)
src/argilla/client/sdk/commons/api.py 54.90% <0.00%> (ø)
src/argilla/client/sdk/text2text/api.py 0.00% <ø> (ø)
src/argilla/client/sdk/token_classification/api.py 0.00% <ø> (ø)
src/argilla/client/sdk/users/api.py 100.00% <ø> (ø)
src/argilla/monitoring/base.py 90.40% <ø> (-0.08%) ⬇️
src/argilla/server/apis/v0/handlers/datasets.py 100.00% <ø> (ø)
src/argilla/server/apis/v0/handlers/metrics.py 97.22% <ø> (ø)
...la/server/apis/v0/handlers/token_classification.py 80.00% <ø> (-0.29%) ⬇️
src/argilla/server/server.py 84.09% <ø> (-0.18%) ⬇️
... and 26 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@tomaarsen tomaarsen changed the title Refactor: Replace isort by ruff in CI Refactor: Replace isort by ruff in pre-commit Feb 9, 2023
@tomaarsen
Copy link
Contributor Author

tomaarsen commented Feb 9, 2023

I'm also very interested in adding the following automatic fixes to the pre-commit:
UP, i.e. fixes from pyupgrade.

These errors could be automatically fixed

I'd need confirmation to go ahead with this.

ruff . --select UP
docs\_source\conf.py:121:24: UP015 [*] Unnecessary open mode parameters
docs\_source\conf.py:122:19: UP015 [*] Unnecessary open mode parameters
src\argilla\__init__.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\__main__.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\_constants.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\client\__init__.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\client\api.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\client\apis\base.py:19:19: UP004 [*] Class `AbstractApi` inherits from `object`
src\argilla\client\datasets.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\client\datasets.py:946:25: UP008 [*] Use `super()` instead of `super(__class__, self)`
src\argilla\client\models.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\client\sdk\__init__.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\client\sdk\client.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\client\sdk\commons\__init__.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\client\sdk\commons\api.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\client\sdk\commons\api.py:2:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\client\sdk\commons\models.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\client\sdk\datasets\__init__.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\client\sdk\datasets\api.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\client\sdk\datasets\api.py:35:11: UP032 [*] Use f-string instead of `format` call
src\argilla\client\sdk\datasets\api.py:52:11: UP032 [*] Use f-string instead of `format` call
src\argilla\client\sdk\datasets\api.py:69:11: UP032 [*] Use f-string instead of `format` call
src\argilla\client\sdk\datasets\models.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\client\sdk\text2text\__init__.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\client\sdk\text2text\models.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\client\sdk\text_classification\__init__.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\client\sdk\text_classification\api.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\client\sdk\text_classification\models.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\client\sdk\token_classification\__init__.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\client\sdk\token_classification\models.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\labeling\__init__.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\labeling\text_classification\__init__.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\labeling\text_classification\label_errors.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\labeling\text_classification\label_models.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\labeling\text_classification\rule.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\labeling\text_classification\weak_labels.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\logging.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\monitoring\asgi.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\__init__.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\__main__.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\apis\v0\handlers\datasets.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\apis\v0\handlers\info.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\apis\v0\handlers\metrics.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\apis\v0\handlers\text2text.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\apis\v0\handlers\text_classification.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\apis\v0\handlers\token_classification.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\apis\v0\handlers\users.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\apis\v0\models\commons\model.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\apis\v0\models\datasets.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\apis\v0\models\text2text.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\apis\v0\models\text_classification.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\apis\v0\models\token_classification.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\app.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\daos\backend\query_helpers.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\daos\datasets.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\daos\models\records.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\daos\records.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\helpers.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\routes.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\security\__init__.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\security\auth_provider\__init__.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\security\auth_provider\base.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\security\auth_provider\local\__init__.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\security\auth_provider\local\provider.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\security\auth_provider\local\settings.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\security\auth_provider\local\users\__init__.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\security\auth_provider\local\users\dao.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\security\auth_provider\local\users\dao.py:70:9: UP028 [*] Replace `yield` over `for` loop with `yield from`
src\argilla\server\security\auth_provider\local\users\model.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\security\auth_provider\local\users\service.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\security\auth_provider\local\users\settings.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\security\factory.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\security\model.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\security\settings.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\server.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\services\datasets.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\services\info.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\services\tasks\text2text\service.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\services\tasks\text_classification\model.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\services\tasks\text_classification\service.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\services\tasks\token_classification\metrics.py:292:24: UP008 [*] Use `super()` instead of `super(__class__, self)`
src\argilla\server\services\tasks\token_classification\model.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\services\tasks\token_classification\service.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\settings.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\server\static_rewrite.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\utils\__init__.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\utils\span_utils.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
src\argilla\utils\utils.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\__init__.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\client\__init__.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\client\sdk\__init__.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\client\sdk\commons\__init__.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\client\sdk\commons\api.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\client\sdk\conftest.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\client\sdk\datasets\__init__.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\client\sdk\datasets\test_api.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\client\sdk\datasets\test_models.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\client\sdk\text2text\__init__.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\client\sdk\text2text\test_models.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\client\sdk\text_classification\__init__.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\client\sdk\text_classification\test_models.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\client\sdk\token_classification\__init__.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\client\sdk\token_classification\test_models.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\client\test_api.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\client\test_asgi.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\client\test_dataset.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\client\test_models.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\labeling\__init__.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\labeling\text_classification\__init__.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\labeling\text_classification\conftest.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\labeling\text_classification\test_label_errors.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\labeling\text_classification\test_label_models.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\labeling\text_classification\test_rule.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\labeling\text_classification\test_weak_labels.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\metrics\test_common_metrics.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\metrics\test_text_classification.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\server\__init__.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\server\datasets\__init__.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\server\datasets\test_api.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\server\datasets\test_dao.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\server\datasets\test_model.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\server\info\__init__.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\server\info\test_api.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\server\metrics\test_api.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\server\test_api.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\server\test_app.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\server\text_classification\__init__.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\server\text_classification\test_api.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\server\text_classification\test_model.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\server\token_classification\__init__.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\server\token_classification\test_api.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\server\token_classification\test_model.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\test_init.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\test_logging.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\utils\__init__.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\utils\test_span_utils.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
tests\utils\test_utils.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
Found 137 errors.
[*] 137 potentially fixable with the --fix option.

Same with flake8-comprehensions errors:

These errors could be automatically fixed
ruff . --select C4       
src\argilla\client\apis\datasets.py:286:37: C416 [*] Unnecessary `list` comprehension (rewrite using `list()`)
src\argilla\client\datasets.py:101:16: C416 [*] Unnecessary `list` comprehension (rewrite using `list()`)
src\argilla\client\datasets.py:663:13: C408 [*] Unnecessary `dict` call (rewrite as a literal)
src\argilla\client\datasets.py:987:13: C408 [*] Unnecessary `dict` call (rewrite as a literal)
src\argilla\client\datasets.py:1270:13: C408 [*] Unnecessary `dict` call (rewrite as a literal)
src\argilla\client\models.py:255:32: C408 [*] Unnecessary `dict` call (rewrite as a literal)
src\argilla\client\models.py:268:32: C408 [*] Unnecessary `dict` call (rewrite as a literal)
src\argilla\labeling\text_classification\weak_labels.py:607:13: C401 [*] Unnecessary generator (rewrite as a `set` comprehension)
src\argilla\labeling\text_classification\weak_labels.py:753:29: C417 Unnecessary `map` usage (rewrite using a generator expression)
src\argilla\labeling\text_classification\weak_labels.py:883:18: C414 Unnecessary `list` call within `sorted()`
src\argilla\labeling\text_classification\weak_labels.py:1003:13: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension)
src\argilla\labeling\text_classification\weak_labels.py:1136:29: C417 Unnecessary `map` usage (rewrite using a generator expression)
src\argilla\metrics\helpers.py:96:43: C408 [*] Unnecessary `dict` call (rewrite as a literal)
src\argilla\metrics\helpers.py:111:43: C408 [*] Unnecessary `dict` call (rewrite as a literal)
src\argilla\monitoring\_flair.py:38:16: C408 [*] Unnecessary `dict` call (rewrite as a literal)
src\argilla\monitoring\_spacy.py:67:16: C408 [*] Unnecessary `dict` call (rewrite as a literal)
src\argilla\monitoring\_transformers.py:80:16: C408 [*] Unnecessary `dict` call (rewrite as a literal)
src\argilla\monitoring\asgi.py:96:24: C408 [*] Unnecessary `dict` call (rewrite as a literal)
src\argilla\monitoring\asgi.py:122:29: C408 [*] Unnecessary `dict` call (rewrite as a literal)
src\argilla\monitoring\asgi.py:231:16: C408 [*] Unnecessary `dict` call (rewrite as a literal)
src\argilla\server\apis\v0\handlers\text2text.py:180:21: C417 Unnecessary `map` usage (rewrite using a generator expression)
src\argilla\server\apis\v0\handlers\text_classification.py:235:21: C417 Unnecessary `map` usage (rewrite using a generator expression)
src\argilla\server\apis\v0\handlers\token_classification.py:204:21: C417 Unnecessary `map` usage (rewrite using a generator expression)
src\argilla\server\apis\v0\validators\text_classification.py:69:32: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension)
src\argilla\server\apis\v0\validators\text_classification.py:90:32: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension)
src\argilla\server\apis\v0\validators\token_classification.py:70:32: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension)
src\argilla\server\apis\v0\validators\token_classification.py:93:32: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension)
src\argilla\server\commons\config.py:37:28: C408 [*] Unnecessary `dict` call (rewrite as a literal)
src\argilla\server\commons\config.py:58:16: C416 [*] Unnecessary `list` comprehension (rewrite using `list()`)
src\argilla\server\daos\backend\client_adapters\factory.py:49:28: C408 [*] Unnecessary `dict` call (rewrite as a literal)
src\argilla\server\daos\backend\mappings\helpers.py:118:42: C416 [*] Unnecessary `list` comprehension (rewrite using `list()`)
src\argilla\server\daos\backend\query_helpers.py:77:21: C416 [*] Unnecessary `list` comprehension (rewrite using `list()`)
src\argilla\server\daos\datasets.py:90:19: C416 [*] Unnecessary `list` comprehension (rewrite using `list()`)
src\argilla\server\daos\datasets.py:214:16: C416 [*] Unnecessary `list` comprehension (rewrite using `list()`)
src\argilla\server\security\auth_provider\local\users\service.py:77:13: C401 [*] Unnecessary generator (rewrite as a `set` comprehension)
src\argilla\server\services\tasks\text_classification\labeling_rules_service.py:99:27: C408 [*] Unnecessary `dict` call (rewrite as a literal)
src\argilla\server\services\tasks\text_classification\labeling_rules_service.py:126:27: C408 [*] Unnecessary `dict` call (rewrite as a literal)
src\argilla\server\services\tasks\token_classification\metrics.py:239:17: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension)
src\argilla\utils\utils.py:146:22: C417 Unnecessary `map` usage (rewrite using a generator expression)
tests\client\functional_tests\test_scan_raw_records.py:40:12: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension)
tests\client\functional_tests\test_scan_raw_records.py:40:16: C416 [*] Unnecessary `list` comprehension (rewrite using `list()`)
tests\client\test_dataset.py:122:23: C408 [*] Unnecessary `dict` call (rewrite as a literal)
tests\client\test_models.py:58:16: C408 [*] Unnecessary `dict` call (rewrite as a literal)
tests\client\test_models.py:64:16: C408 [*] Unnecessary `dict` call (rewrite as a literal)
tests\client\test_models.py:224:44: C408 [*] Unnecessary `dict` call (rewrite as a literal)
tests\functional_tests\datasets\test_delete_records_from_datasets.py:30:57: C408 [*] Unnecessary `dict` call (rewrite as a literal)
tests\functional_tests\datasets\test_delete_records_from_datasets.py:62:57: C408 [*] Unnecessary `dict` call (rewrite as a literal)
tests\functional_tests\datasets\test_delete_records_from_datasets.py:106:26: C408 [*] Unnecessary `dict` call (rewrite as a literal)
tests\functional_tests\test_log_for_text_classification.py:226:20: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension)
tests\functional_tests\test_log_for_token_classification.py:531:20: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension)
tests\labeling\text_classification\test_label_errors.py:186:17: C410 [*] Unnecessary `list` literal passed to `list()` (remove the outer call to `list()`)
tests\labeling\text_classification\test_label_errors.py:187:17: C410 [*] Unnecessary `list` literal passed to `list()` (remove the outer call to `list()`)
tests\labeling\text_classification\test_rule.py:283:13: C408 [*] Unnecessary `dict` call (rewrite as a literal)
tests\labeling\text_classification\test_rule.py:293:13: C408 [*] Unnecessary `dict` call (rewrite as a literal)
tests\labeling\text_classification\test_rule.py:303:13: C408 [*] Unnecessary `dict` call (rewrite as a literal)
tests\labeling\text_classification\test_rule.py:330:13: C408 [*] Unnecessary `dict` call (rewrite as a literal)
tests\labeling\text_classification\test_rule.py:340:13: C408 [*] Unnecessary `dict` call (rewrite as a literal)
tests\labeling\text_classification\test_rule.py:350:13: C408 [*] Unnecessary `dict` call (rewrite as a literal)
tests\labeling\text_classification\test_weak_labels.py:899:13: C417 Unnecessary `map` usage (rewrite using a generator expression)
tests\monitoring\test_transformers_monitoring.py:63:12: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension)
tests\server\daos\models\test_records.py:27:33: C408 [*] Unnecessary `dict` call (rewrite as a literal)
tests\server\daos\models\test_records.py:31:33: C408 [*] Unnecessary `dict` call (rewrite as a literal)
tests\server\datasets\test_api.py:45:15: C408 [*] Unnecessary `dict` call (rewrite as a literal)
tests\server\datasets\test_api.py:78:15: C408 [*] Unnecessary `dict` call (rewrite as a literal)
tests\server\text_classification\test_api.py:451:12: C417 Unnecessary `map` usage (rewrite using a `list` comprehension)
tests\server\text_classification\test_api.py:451:17: C417 Unnecessary `map` usage (rewrite using a generator expression)
tests\server\text_classification\test_api.py:531:12: C417 Unnecessary `map` usage (rewrite using a `list` comprehension)
tests\server\text_classification\test_api.py:531:17: C417 Unnecessary `map` usage (rewrite using a generator expression)
tests\server\text_classification\test_api.py:623:16: C417 Unnecessary `map` usage (rewrite using a generator expression)
Found 69 errors.
[*] 56 potentially fixable with the --fix option.

Same with flake8-pytest-style errors:

These errors could be automatically fixed
ruff . --select PT      
src\argilla\client\sdk\token_classification\models.py:55:9: PT018 Assertion should be broken down into multiple parts
src\argilla\server\apis\v0\models\token_classification.py:60:9: PT018 Assertion should be broken down into multiple parts
src\argilla\server\services\tasks\text_classification\model.py:201:13: PT018 Assertion should be broken down into multiple parts
tests\client\apis\test_base.py:25:5: PT012 `pytest.raises()` block should contain a single simple statement
tests\client\conftest.py:55:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\client\conftest.py:139:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\client\conftest.py:231:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\client\conftest.py:309:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\client\conftest.py:383:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\client\sdk\commons\api.py:67:5: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\client\sdk\commons\api.py:98:5: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\client\sdk\commons\api.py:127:9: PT018 Assertion should be broken down into multiple parts
tests\client\sdk\commons\test_client.py:35:28: PT011 `pytest.raises(Exception)` is too broad, set the `match` parameter or use a more specific exception
tests\client\sdk\conftest.py:141:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\client\sdk\conftest.py:150:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\client\sdk\conftest.py:179:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\client\sdk\conftest.py:203:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\client\sdk\datasets\test_api.py:29:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\client\sdk\datasets\test_api.py:53:5: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\client\sdk\text2text\test_models.py:51:5: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\client\sdk\text2text\test_models.py:75:5: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\client\sdk\text_classification\test_models.py:94:5: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\client\sdk\text_classification\test_models.py:108:5: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\client\sdk\text_classification\test_models.py:131:5: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\client\sdk\token_classification\test_models.py:53:5: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\client\sdk\token_classification\test_models.py:74:5: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\client\sdk\users\test_api.py:28:5: PT012 `pytest.raises()` block should contain a single simple statement
tests\client\test_api.py:53:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\client\test_api.py:54:1: PT004 Fixture `mock_response_200` does not return anything, add leading underscore
tests\client\test_api.py:66:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\client\test_api.py:67:1: PT004 Fixture `mock_response_500` does not return anything, add leading underscore
tests\client\test_api.py:79:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\client\test_api.py:80:1: PT004 Fixture `mock_response_token_401` does not return anything, add leading underscore
tests\client\test_api.py:285:5: PT012 `pytest.raises()` block should contain a single simple statement
tests\client\test_api.py:293:5: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\client\test_api.py:313:5: PT012 `pytest.raises()` block should contain a single simple statement
tests\client\test_api.py:321:5: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\client\test_api.py:609:5: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\client\test_client_errors.py:20:5: PT012 `pytest.raises()` block should contain a single simple statement
tests\client\test_dataset.py:552:9: PT018 Assertion should be broken down into multiple parts
tests\client\test_dataset.py:634:28: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception
tests\client\test_dataset.py:932:5: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\client\test_dataset.py:951:5: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\client\test_models.py:202:5: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\client\test_models.py:298:5: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\conftest.py:32:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\conftest.py:43:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\conftest.py:73:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\functional_tests\search\test_search_service.py:33:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\functional_tests\search\test_search_service.py:38:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\functional_tests\search\test_search_service.py:43:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\functional_tests\search\test_search_service.py:48:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\functional_tests\test_log_for_text_classification.py:53:24: PT011 `pytest.raises(Exception)` is too broad, set the `match` parameter or use a more specific exception
tests\functional_tests\test_log_for_text_classification.py:335:9: PT017 Found assertion on exception `error` in except block, use `pytest.raises()` instead
tests\labeling\text_classification\conftest.py:20:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\labeling\text_classification\test_label_errors.py:94:5: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\labeling\text_classification\test_label_errors.py:233:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\labeling\text_classification\test_label_models.py:36:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\labeling\text_classification\test_label_models.py:64:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\labeling\text_classification\test_label_models.py:86:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\labeling\text_classification\test_label_models.py:154:9: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\labeling\text_classification\test_label_models.py:205:9: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\labeling\text_classification\test_label_models.py:270:9: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\labeling\text_classification\test_label_models.py:307:9: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\labeling\text_classification\test_label_models.py:338:13: PT018 Assertion should be broken down into multiple parts
tests\labeling\text_classification\test_label_models.py:342:9: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\labeling\text_classification\test_label_models.py:414:9: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\labeling\text_classification\test_label_models.py:463:9: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\labeling\text_classification\test_label_models.py:536:30: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\labeling\text_classification\test_label_models.py:608:30: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\labeling\text_classification\test_label_models.py:643:9: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\labeling\text_classification\test_label_models.py:799:9: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\labeling\text_classification\test_rule.py:34:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\labeling\text_classification\test_rule.py:57:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\labeling\text_classification\test_rule.py:87:5: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\labeling\text_classification\test_rule.py:163:5: PT018 Assertion should be broken down into multiple parts
tests\labeling\text_classification\test_rule.py:279:5: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\labeling\text_classification\test_rule.py:326:5: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\labeling\text_classification\test_weak_labels.py:39:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\labeling\text_classification\test_weak_labels.py:72:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\labeling\text_classification\test_weak_labels.py:94:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\labeling\text_classification\test_weak_labels.py:128:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\labeling\text_classification\test_weak_labels.py:265:9: PT012 `pytest.raises()` block should contain a single simple statement
tests\labeling\text_classification\test_weak_labels.py:283:9: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\labeling\text_classification\test_weak_labels.py:557:6: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\labeling\text_classification\test_weak_labels.py:830:6: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\listeners\test_listener.py:26:9: PT018 Assertion should be broken down into multiple parts
tests\listeners\test_listener.py:85:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception
tests\listeners\test_listener.py:93:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception
tests\metrics\test_common_metrics.py:21:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\metrics\test_text_classification.py:43:5: PT018 Assertion should be broken down into multiple parts
tests\metrics\test_text_classification.py:62:5: PT018 Assertion should be broken down into multiple parts
tests\monitoring\test_transformers_monitoring.py:75:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\monitoring\test_transformers_monitoring.py:80:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\monitoring\test_transformers_monitoring.py:96:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\monitoring\test_transformers_monitoring.py:158:2: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
tests\monitoring\test_transformers_monitoring.py:282:24: PT011 `pytest.raises(Exception)` is too broad, set the `match` parameter or use a more specific exception
tests\server\backend\test_query_builder.py:25:5: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\server\backend\test_query_builder.py:74:24: PT011 `pytest.raises(Exception)` is too broad, set the `match` parameter or use a more specific exception
tests\server\commons\test_telemetry.py:26:2: PT023 [*] Use `@pytest.mark.asyncio()` over `@pytest.mark.asyncio`
tests\server\commons\test_telemetry.py:43:2: PT023 [*] Use `@pytest.mark.asyncio()` over `@pytest.mark.asyncio`
tests\server\commons\test_telemetry.py:53:2: PT023 [*] Use `@pytest.mark.asyncio()` over `@pytest.mark.asyncio`
tests\server\security\test_dao.py:29:2: PT023 [*] Use `@pytest.mark.asyncio()` over `@pytest.mark.asyncio`
tests\server\security\test_model.py:99:5: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\server\security\test_provider.py:27:2: PT023 [*] Use `@pytest.mark.asyncio()` over `@pytest.mark.asyncio`
tests\server\security\test_provider.py:34:2: PT023 [*] Use `@pytest.mark.asyncio()` over `@pytest.mark.asyncio`
tests\server\security\test_provider.py:43:2: PT023 [*] Use `@pytest.mark.asyncio()` over `@pytest.mark.asyncio`
tests\server\security\test_service.py:33:2: PT023 [*] Use `@pytest.mark.asyncio()` over `@pytest.mark.asyncio`
tests\server\text_classification\test_model.py:192:9: PT017 Found assertion on exception `e` in except block, use `pytest.raises()` instead
tests\utils\test_span_utils.py:89:5: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
tests\utils\test_span_utils.py:132:5: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple`
Found 111 errors.
[*] 83 potentially fixable with the --fix option.

@tomaarsen
Copy link
Contributor Author

Resolved merge conflict in 81ade4f.

Copy link
Member

@frascuchon frascuchon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow! Thanks for this, @tomaarsen

@frascuchon frascuchon merged commit 5f0627c into argilla-io:develop Feb 14, 2023
@tomaarsen tomaarsen deleted the hotfix/replace_isort_by_ruff branch February 14, 2023 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: ci Indicates that an issue or pull request is related to the Continuous Integration (CI)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants