Skip to content

Commit

Permalink
ci: update ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethEnevoldsen committed Oct 30, 2024
1 parent 8a97e82 commit 81ae227
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 50 deletions.
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ lint:
ruff format . # running ruff formatting
ruff check src/ --fix # running ruff linting
ruff check tests/ --fix
ruff docs/conf.py --fix
ruff check docs/conf.py --fix

test:
@echo "--- 🧪 Running tests ---"
Expand Down
83 changes: 42 additions & 41 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,7 @@ repository = "https://github.com/centre-for-humanities-computing/DaCy"
file = "LICENSE"
name = "Apache License 2.0"
[project.optional-dependencies]
dev = [
"cruft>=2.0.0",
"pyright>=1.1.339",
"ruff>=0.0.270",
]
dev = ["cruft>=2.0.0", "pyright>=1.1.339", "ruff==0.7.1"]
tests = ["pytest>=7.1.2", "pytest-cov>=3.0.0", "pytest-instafail>=0.4.2"]
docs = [
"sphinx==5.3.0",
Expand Down Expand Up @@ -110,6 +106,42 @@ pythonPlatform = "Darwin"

[tool.ruff]
# extend-include = ["*.ipynb"]

# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".hg",
".nox",
".pants.d",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
"__init__.py",
".venv",
".env",
".git",
"__pycache__",
"dev/**",
"training/main/**",
"training/ner_fine_grained/**",
"papers/DaCy-A-Unified-Framework-for-Danish-NLP/**",
"docs/performance_testing_utils/**",
]
target-version = "py38"

[tool.ruff.lint]
# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default.
select = [
"A",
Expand Down Expand Up @@ -150,54 +182,23 @@ ignore = [
"ANN202",
"COM812",
]
ignore-init-module-imports = true
# Allow autofix for all enabled rules (when `--fix`) is provided.
unfixable = ["ERA"]
# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".hg",
".nox",
".pants.d",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
"__init__.py",
".venv",
".env",
".git",
"__pycache__",
"dev/**",
"training/main/**",
"training/ner_fine_grained/**",
"papers/DaCy-A-Unified-Framework-for-Danish-NLP/**",
"docs/performance_testing_utils/**",
]


# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
target-version = "py38"


[tool.ruff.lint.pydocstyle]
convention = "google"

[tool.ruff.flake8-annotations]
[tool.ruff.lint.flake8-annotations]
mypy-init-return = true
suppress-none-returning = true


[tool.ruff.mccabe]
[tool.ruff.lint.mccabe]
# Unlike Flake8, default to a complexity level of 10.
max-complexity = 10

Expand Down
1 change: 1 addition & 0 deletions src/dacy/download.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Functions for downloading DaCy models."""

import os
from importlib.metadata import version
from pathlib import Path
Expand Down
1 change: 1 addition & 0 deletions src/dacy/load.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Functionality for loading and locating DaCy models."""

import warnings
from pathlib import Path
from typing import Any, Union
Expand Down
1 change: 1 addition & 0 deletions src/dacy/score/input_length.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Contains functions for testing the performance of models on varying input
length."""

from typing import Callable, List, Union

import pandas as pd
Expand Down
3 changes: 2 additions & 1 deletion src/dacy/score/score.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This includes function for scoring models applied to a SpaCy corpus."""

from __future__ import annotations

from copy import copy
Expand Down Expand Up @@ -163,7 +164,7 @@ def __score(augmenter): # noqa: ANN001

# and collapse list to dict
for key in scores: # type: ignore
scores[key] = [s[key] if key in s else None for s in scores_ls] # type: ignore
scores[key] = [s.get([key], None) for s in scores_ls] # type: ignore

scores["k"] = list(range(k)) # type: ignore

Expand Down
5 changes: 3 additions & 2 deletions tests/test_datasets.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import dacy
from dacy.datasets import dane, female_names, male_names, muslim_names
from spacy.lang.da import Danish
from spacy.training import Example
from spacy.training.corpus import Corpus

import dacy
from dacy.datasets import dane, female_names, male_names, muslim_names


def test_dane():
train, dev, test = dane(open_unverified_connection=True) # type: ignore
Expand Down
3 changes: 2 additions & 1 deletion tests/test_download.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import dacy
import pytest

import dacy
from dacy.load import load


Expand Down
3 changes: 2 additions & 1 deletion tests/test_hate_speech.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import dacy
import spacy

import dacy


def test_add_hate_speech_detection():
nlp = spacy.blank("da")
Expand Down
5 changes: 3 additions & 2 deletions tests/test_score.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import pandas as pd
from dacy.datasets import dane
from dacy.score import n_sents_score, score
from spacy.lang.da import Danish
from spacy.training.augment import create_lower_casing_augmenter

from dacy.datasets import dane
from dacy.score import n_sents_score, score


def test_score():
nlp = Danish()
Expand Down
3 changes: 2 additions & 1 deletion tests/test_sentiment.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import dacy
import spacy

import dacy


def test_add_subjectivity():
nlp = spacy.blank("da")
Expand Down

0 comments on commit 81ae227

Please sign in to comment.