Skip to content

Commit

Permalink
chore: update ruff linting scripts and settings (#1105)
Browse files Browse the repository at this point in the history
* updates

* more changes

* lint

* more changes

* more changes

* mmore and more changes

* right concurrency group for anthropic

* apply suggestions
  • Loading branch information
anakin87 authored and Amnah199 committed Oct 2, 2024
1 parent 290ba72 commit c5919c2
Show file tree
Hide file tree
Showing 50 changed files with 253 additions and 178 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/anthropic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ defaults:
working-directory: integrations/anthropic

concurrency:
group: cohere-${{ github.head_ref }}
group: anthropic-${{ github.head_ref }}
cancel-in-progress: true

env:
Expand Down
10 changes: 6 additions & 4 deletions integrations/amazon_bedrock/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ typing = "mypy --install-types --non-interactive --explicit-package-bases {args:

style = ["ruff check {args:.}", "black --check --diff {args:.}"]

fmt = ["black {args:.}", "ruff --fix {args:.}", "style"]
fmt = ["black {args:.}", "ruff check --fix {args:.}", "style"]

all = ["style", "typing"]

Expand All @@ -79,6 +79,8 @@ skip-string-normalization = true
[tool.ruff]
target-version = "py38"
line-length = 120

[tool.ruff.lint]
select = [
"A",
"ARG",
Expand Down Expand Up @@ -128,13 +130,13 @@ unfixable = [
"F401",
]

[tool.ruff.isort]
[tool.ruff.lint.isort]
known-first-party = ["haystack_integrations"]

[tool.ruff.flake8-tidy-imports]
[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "parents"

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
# Tests can use magic values, assertions, and relative imports
"tests/**/*" = ["PLR2004", "S101", "TID252"]

Expand Down
10 changes: 6 additions & 4 deletions integrations/amazon_sagemaker/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ dependencies = ["black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243"]
[tool.hatch.envs.lint.scripts]
typing = "mypy --install-types --non-interactive --explicit-package-bases {args:src/ tests}"
style = ["ruff check {args:.}", "black --check --diff {args:.}"]
fmt = ["black {args:.}", "ruff --fix {args:.}", "style"]
fmt = ["black {args:.}", "ruff check --fix {args:.}", "style"]
all = ["style", "typing"]

[tool.black]
Expand All @@ -81,6 +81,8 @@ skip-string-normalization = true
[tool.ruff]
target-version = "py38"
line-length = 120

[tool.ruff.lint]
select = [
"A",
"ARG",
Expand Down Expand Up @@ -131,13 +133,13 @@ unfixable = [
"F401",
]

[tool.ruff.isort]
[tool.ruff.lint.isort]
known-first-party = ["haystack_integrations"]

[tool.ruff.flake8-tidy-imports]
[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "parents"

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
# Tests can use magic values, assertions, and relative imports
"tests/**/*" = ["PLR2004", "S101", "TID252"]

Expand Down
10 changes: 6 additions & 4 deletions integrations/anthropic/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ typing = "mypy --install-types --non-interactive --explicit-package-bases {args:

style = ["ruff check {args:.}", "black --check --diff {args:.}"]

fmt = ["black {args:.}", "ruff --fix {args:.}", "style"]
fmt = ["black {args:.}", "ruff check --fix {args:.}", "style"]

all = ["style", "typing"]

Expand All @@ -79,6 +79,8 @@ skip-string-normalization = true
[tool.ruff]
target-version = "py38"
line-length = 120

[tool.ruff.lint]
select = [
"A",
"ARG",
Expand Down Expand Up @@ -129,13 +131,13 @@ unfixable = [
"F401",
]

[tool.ruff.isort]
[tool.ruff.lint.isort]
known-first-party = ["haystack_integrations"]

[tool.ruff.flake8-tidy-imports]
[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "parents"

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
# Tests can use magic values, assertions, and relative imports
"tests/**/*" = ["PLR2004", "S101", "TID252"]

Expand Down
9 changes: 5 additions & 4 deletions integrations/astra/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ skip-string-normalization = true
[tool.ruff]
target-version = "py38"
line-length = 120
lint.select = [

[tool.ruff.lint]
select = [
"A",
"ARG",
"B",
Expand All @@ -105,7 +107,7 @@ lint.select = [
"W",
"YTT",
]
lint.ignore = [
ignore = [
# Allow non-abstract empty methods in abstract base classes
"B027",
# Allow boolean positional values in function calls, like `dict.get(... True)`
Expand All @@ -121,11 +123,10 @@ lint.ignore = [
"PLR0913",
"PLR0915",
]
lint.unfixable = [
unfixable = [
# Don't touch unused imports
"F401",
]
lint.exclude = ["example"]

[tool.ruff.lint.isort]
known-first-party = ["haystack_integrations"]
Expand Down
20 changes: 11 additions & 9 deletions integrations/chroma/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ dependencies = [
]
[tool.hatch.envs.lint.scripts]
typing = "mypy --install-types --non-interactive --explicit-package-bases {args:src/ tests}"
style = ["ruff check {args:. --exclude tests/}", "black --check --diff {args:.}"]
fmt = ["black {args:.}", "ruff --fix {args:. --exclude tests/}", "style"]
style = ["ruff check {args:.}", "black --check --diff {args:.}"]
fmt = ["black {args:.}", "ruff check --fix {args:.}", "style"]
all = ["style", "typing"]

[tool.hatch.metadata]
Expand All @@ -85,7 +85,9 @@ skip-string-normalization = true
[tool.ruff]
target-version = "py38"
line-length = 120
lint.select = [

[tool.ruff.lint]
select = [
"A",
"ARG",
"B",
Expand All @@ -112,7 +114,7 @@ lint.select = [
"W",
"YTT",
]
lint.ignore = [
ignore = [
# Allow non-abstract empty methods in abstract base classes
"B027",
# Allow boolean positional values in function calls, like `dict.get(... True)`
Expand All @@ -130,19 +132,19 @@ lint.ignore = [
# Ignore unused params
"ARG002",
]
lint.unfixable = [
unfixable = [
# Don't touch unused imports
"F401",
]
exclude = ["example"]

[tool.ruff.isort]
known-first-party = ["src", "example", "tests"]
[tool.ruff.lint.isort]
known-first-party = ["haystack_integrations"]

[tool.ruff.flake8-tidy-imports]
[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "parents"

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
# Tests can use magic values, assertions, and relative imports
"tests/**/*" = ["PLR2004", "S101", "TID252"]
"example/**/*" = ["T201"]
Expand Down
2 changes: 1 addition & 1 deletion integrations/chroma/tests/test_document_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# SPDX-License-Identifier: Apache-2.0
import logging
import operator
import sys
import uuid
from typing import List
from unittest import mock
import sys

import numpy as np
import pytest
Expand Down
14 changes: 8 additions & 6 deletions integrations/cohere/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ dependencies = ["black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243"]
[tool.hatch.envs.lint.scripts]
typing = "mypy --install-types --non-interactive --explicit-package-bases {args:src/ tests}"
style = [
"ruff check {args:. --exclude tests/}",
"ruff check {args:.}",
"black --check --diff {args:.}",
]
fmt = ["black {args:.}", "ruff --fix {args:. --exclude tests/}", "style"]
fmt = ["black {args:.}", "ruff check --fix {args:}", "style"]
all = ["style", "typing"]

[tool.black]
Expand All @@ -79,6 +79,8 @@ skip-string-normalization = true
[tool.ruff]
target-version = "py38"
line-length = 120

[tool.ruff.lint]
select = [
"A",
"ARG",
Expand Down Expand Up @@ -127,13 +129,13 @@ unfixable = [
"F401",
]

[tool.ruff.isort]
known-first-party = ["src"]
[tool.ruff.lint.isort]
known-first-party = ["haystack_integrations"]

[tool.ruff.flake8-tidy-imports]
[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "parents"

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
# Tests can use magic values, assertions, and relative imports
"tests/**/*" = ["PLR2004", "S101", "TID252"]

Expand Down
1 change: 1 addition & 0 deletions integrations/cohere/tests/test_cohere_chat_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from haystack.components.generators.utils import print_streaming_chunk
from haystack.dataclasses import ChatMessage, ChatRole, StreamingChunk
from haystack.utils import Secret

from haystack_integrations.components.generators.cohere import CohereChatGenerator

pytestmark = pytest.mark.chat_generators
Expand Down
1 change: 1 addition & 0 deletions integrations/cohere/tests/test_cohere_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from cohere.core import ApiError
from haystack.components.generators.utils import print_streaming_chunk
from haystack.utils import Secret

from haystack_integrations.components.generators.cohere import CohereGenerator

pytestmark = pytest.mark.generators
Expand Down
1 change: 1 addition & 0 deletions integrations/cohere/tests/test_cohere_ranker.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pytest
from haystack import Document
from haystack.utils.auth import Secret

from haystack_integrations.components.rankers.cohere import CohereRanker

pytestmark = pytest.mark.ranker
Expand Down
1 change: 1 addition & 0 deletions integrations/cohere/tests/test_document_embedder.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pytest
from haystack import Document
from haystack.utils import Secret

from haystack_integrations.components.embedders.cohere import CohereDocumentEmbedder

pytestmark = pytest.mark.embedders
Expand Down
1 change: 1 addition & 0 deletions integrations/cohere/tests/test_text_embedder.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import pytest
from haystack.utils import Secret

from haystack_integrations.components.embedders.cohere import CohereTextEmbedder

pytestmark = pytest.mark.embedders
Expand Down
1 change: 1 addition & 0 deletions integrations/deepeval/example/example.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# A valid OpenAI API key is required to run this example.

from haystack import Pipeline

from haystack_integrations.components.evaluators.deepeval import DeepEvalEvaluator, DeepEvalMetric

QUESTIONS = [
Expand Down
14 changes: 8 additions & 6 deletions integrations/deepeval/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ dependencies = ["black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243"]
[tool.hatch.envs.lint.scripts]
typing = "mypy --install-types --non-interactive {args:src/}"
style = ["ruff check {args:.}", "black --check --diff {args:.}"]
fmt = ["black {args:.}", "ruff --fix {args:.}", "style"]
fmt = ["black {args:.}", "ruff check --fix {args:.}", "style"]
all = ["style", "typing"]

[tool.black]
Expand All @@ -71,6 +71,9 @@ skip-string-normalization = true
[tool.ruff]
target-version = "py38"
line-length = 120
exclude = ["example", "tests"]

[tool.ruff.lint]
select = [
"A",
"ARG",
Expand Down Expand Up @@ -121,15 +124,14 @@ unfixable = [
# Don't touch unused imports
"F401",
]
extend-exclude = ["tests", "example"]

[tool.ruff.isort]
known-first-party = ["src"]
[tool.ruff.lint.isort]
known-first-party = ["haystack_integrations"]

[tool.ruff.flake8-tidy-imports]
[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "all"

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
# Tests can use magic values, assertions, and relative imports
"tests/**/*" = ["PLR2004", "S101", "TID252"]

Expand Down
2 changes: 1 addition & 1 deletion integrations/deepeval/tests/test_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
from unittest.mock import patch

import pytest
from deepeval.evaluate import BaseMetric, TestResult
from haystack import DeserializationError

from haystack_integrations.components.evaluators.deepeval import DeepEvalEvaluator, DeepEvalMetric
from deepeval.evaluate import TestResult, BaseMetric

DEFAULT_QUESTIONS = [
"Which is the most popular global sport?",
Expand Down
14 changes: 8 additions & 6 deletions integrations/elasticsearch/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ detached = true
dependencies = ["black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243"]
[tool.hatch.envs.lint.scripts]
typing = "mypy --install-types --non-interactive --explicit-package-bases {args:src/ tests}"
style = ["ruff check {args:. --exclude tests/}", "black --check --diff {args:.}"]
fmt = ["black {args:.}", "ruff --fix {args:. --exclude tests/}", "style"]
style = ["ruff check {args:}", "black --check --diff {args:.}"]
fmt = ["black {args:.}", "ruff check --fix {args:}", "style"]
all = ["style", "typing"]

[tool.hatch.metadata]
Expand All @@ -80,6 +80,8 @@ skip-string-normalization = true
[tool.ruff]
target-version = "py38"
line-length = 120

[tool.ruff.lint]
select = [
"A",
"ARG",
Expand Down Expand Up @@ -128,13 +130,13 @@ unfixable = [
"F401",
]

[tool.ruff.isort]
known-first-party = ["src"]
[tool.ruff.lint.isort]
known-first-party = ["haystack_integrations"]

[tool.ruff.flake8-tidy-imports]
[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "parents"

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
# Tests can use magic values, assertions, and relative imports
"tests/**/*" = ["PLR2004", "S101", "TID252"]

Expand Down
Loading

0 comments on commit c5919c2

Please sign in to comment.