From 76abfdd0bf418b8310835a5779bcffdee64b65ca Mon Sep 17 00:00:00 2001 From: Kenneth Enevoldsen Date: Wed, 6 Dec 2023 22:57:03 +0100 Subject: [PATCH] fix: ran linting --- .github/workflows/lint.yml | 4 ++-- docs/evaluation/utils.py | 3 ++- docs/performance_ner.ipynb | 3 ++- docs/tutorials/robustness.ipynb | 2 +- docs/tutorials/sentiment.ipynb | 2 +- makefile | 2 +- pyproject.toml | 4 ++-- src/dacy/datasets/dane.py | 4 ++-- src/dacy/datasets/names.py | 6 +++--- src/dacy/download.py | 2 +- tests/test_hate_speech.py | 2 +- tests/test_sentiment.py | 2 +- 12 files changed, 19 insertions(+), 17 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d27e4d45..9f2a0283 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,6 +1,6 @@ # GitHub action to run linting -name: run-pre-commit +name: run linting on: pull_request: @@ -19,7 +19,7 @@ jobs: python-version: "3.9" cache: "pip" - - name: Install pre-commit + - name: Install dependencies run: make install - name: Lint diff --git a/docs/evaluation/utils.py b/docs/evaluation/utils.py index 7de29704..fb78287f 100644 --- a/docs/evaluation/utils.py +++ b/docs/evaluation/utils.py @@ -6,12 +6,13 @@ import numpy as np import pandas as pd import spacy -from evaluation.datasets import datasets from spacy.language import Language from spacy.scorer import Scorer from spacy.tokens import Doc from spacy.training import Example +from evaluation.datasets import datasets + def bootstrap( examples: List[Example], diff --git a/docs/performance_ner.ipynb b/docs/performance_ner.ipynb index 5424eb85..0a291951 100644 --- a/docs/performance_ner.ipynb +++ b/docs/performance_ner.ipynb @@ -70,8 +70,8 @@ "outputs": [], "source": [ "import spacy\n", - "from spacy.tokens import Span\n", "from spacy import displacy\n", + "from spacy.tokens import Span\n", "\n", "text = \"\"\"To kendte russiske historikere Andronik Mirganjan og Igor Klamkin tror ikke, at Rusland kan udvikles uden en \"jernnæve\".\"\"\"\n", "nlp = spacy.blank(\"da\")\n", @@ -549,6 +549,7 @@ ], "source": [ "from functools import partial\n", + "\n", "from evaluation.models import openai_model_loader_fine_ner\n", "\n", "MODELS_ = MODELS.copy()\n", diff --git a/docs/tutorials/robustness.ipynb b/docs/tutorials/robustness.ipynb index 30d48e3e..7f6d35c5 100644 --- a/docs/tutorials/robustness.ipynb +++ b/docs/tutorials/robustness.ipynb @@ -63,8 +63,8 @@ }, "outputs": [], "source": [ - "import spacy\n", "import dacy\n", + "import spacy\n", "\n", "# load models\n", "spacy_small = spacy.load(\"da_core_news_sm\")\n", diff --git a/docs/tutorials/sentiment.ipynb b/docs/tutorials/sentiment.ipynb index a680afe7..782eec96 100644 --- a/docs/tutorials/sentiment.ipynb +++ b/docs/tutorials/sentiment.ipynb @@ -345,8 +345,8 @@ } ], "source": [ - "import spacy\n", "import asent\n", + "import spacy\n", "\n", "# load a spacy pipeline\n", "# equivalent to a dacy.load()\n", diff --git a/makefile b/makefile index d662f628..3779e398 100644 --- a/makefile +++ b/makefile @@ -9,7 +9,7 @@ static-type-check: lint: @echo "--- 🧹 Running linters ---" ruff format . # running ruff formatting - ruff . --fix # running ruff linting + ruff src/ --fix # running ruff linting test: @echo "--- 🧪 Running tests ---" diff --git a/pyproject.toml b/pyproject.toml index a94b79c4..99cdcac7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -105,11 +105,11 @@ where = ["src"] omit = ["**/tests/*", "**/about.py", "**/dev/*"] [tool.pyright] -exclude = [".*venv*", ".tox"] +exclude = [".*venv*"] pythonPlatform = "Darwin" [tool.ruff] -extend-include = ["*.ipynb"] +# extend-include = ["*.ipynb"] # Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default. select = [ "A", diff --git a/src/dacy/datasets/dane.py b/src/dacy/datasets/dane.py index e1332aae..f851caae 100644 --- a/src/dacy/datasets/dane.py +++ b/src/dacy/datasets/dane.py @@ -20,7 +20,7 @@ def dane( # noqa n_sents: int = 1, open_unverified_connection: bool = False, **kwargs, # noqa -) -> Union[List[Corpus], Corpus]: # type: ignore +) -> Union[List[Corpus], Corpus]: # type: ignore """Reads the DaNE dataset as a spacy Corpus. Args: @@ -110,5 +110,5 @@ def dane( # noqa for split in splits: corpora.append(Corpus(save_path / paths[split])) # type: ignore if len(corpora) == 1: - return corpora[0] # type: ignore + return corpora[0] # type: ignore return corpora diff --git a/src/dacy/datasets/names.py b/src/dacy/datasets/names.py index 06365ae4..56d08594 100644 --- a/src/dacy/datasets/names.py +++ b/src/dacy/datasets/names.py @@ -81,7 +81,7 @@ def muslim_names() -> Dict[str, List[str]]: # type: ignore return load_names(ethnicity="muslim") -def danish_names() -> Dict[str, List[str]]: # type: ignore +def danish_names() -> Dict[str, List[str]]: # type: ignore """Returns a dictionary of Danish names. Returns: @@ -98,7 +98,7 @@ def danish_names() -> Dict[str, List[str]]: # type: ignore return load_names(ethnicity="danish") -def female_names() -> Dict[str, List[str]]: # type: ignore +def female_names() -> Dict[str, List[str]]: # type: ignore """Returns a dictionary of Danish female names. Returns: @@ -114,7 +114,7 @@ def female_names() -> Dict[str, List[str]]: # type: ignore return load_names(ethnicity="danish", gender="female", min_prop_gender=0.5) -def male_names() -> Dict[str, List[str]]: # type: ignore +def male_names() -> Dict[str, List[str]]: # type: ignore """Returns a dictionary of Danish male names. Returns: diff --git a/src/dacy/download.py b/src/dacy/download.py index 45f98323..4fbb30e5 100644 --- a/src/dacy/download.py +++ b/src/dacy/download.py @@ -112,7 +112,7 @@ def download_model( + " list of all models", ) - mdl = model.split("-")[0] # type: ignore + mdl = model.split("-")[0] # type: ignore if mdl in get_installed_models() and not force and version(mdl) == mdl_version: return mdl install(models_url[model]) diff --git a/tests/test_hate_speech.py b/tests/test_hate_speech.py index 3ec76c71..cec26d8c 100644 --- a/tests/test_hate_speech.py +++ b/tests/test_hate_speech.py @@ -1,4 +1,4 @@ -import dacy # noqa +import dacy import spacy diff --git a/tests/test_sentiment.py b/tests/test_sentiment.py index 17dbebb9..7b4dd1f5 100644 --- a/tests/test_sentiment.py +++ b/tests/test_sentiment.py @@ -1,4 +1,4 @@ -import dacy # noqa +import dacy import spacy