-
Notifications
You must be signed in to change notification settings - Fork 20
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
Ci: Update ruff and cruft template #291
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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", | ||||||
|
@@ -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" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Align ruff target-version with project's Python requirement. The project requires Python >=3.9, but ruff's target-version is set to py38. Consider updating to: -target-version = "py38"
+target-version = "py39" This alignment ensures ruff uses language features and checks appropriate for your minimum supported Python version. 📝 Committable suggestion
Suggested change
|
||||||
|
||||||
[tool.ruff.lint] | ||||||
# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default. | ||||||
select = [ | ||||||
"A", | ||||||
|
@@ -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 | ||||||
|
||||||
|
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 | ||||||
|
@@ -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 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix critical bug in score aggregation. There's a bug in the dictionary access where a list is incorrectly passed to the Apply this fix: - scores[key] = [s.get([key], None) for s in scores_ls]
+ scores[key] = [s.get(key, None) for s in scores_ls] 📝 Committable suggestion
Suggested change
|
||||||
|
||||||
scores["k"] = list(range(k)) # type: ignore | ||||||
|
||||||
|
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 | ||
|
||
|
||
|
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") | ||
|
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") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove duplicate exclude patterns.
The exclude list contains duplicate entries:
.venv
appears on lines 123 and 132.git
appears on lines 115 and 134Apply this diff to remove duplicates:
📝 Committable suggestion