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

chore: bump dependencies and fix new linter errors #1122

Merged
merged 10 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
repos:

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.6
rev: v0.6.1
hooks:
- id: ruff
args:
- --ignore=A002 # builtin-argument-shadowing
- --ignore=ARG001 # unused function argument
- --ignore=D101 # undocumented-public-class
- --ignore=D102 # undocumented-public-method
- --ignore=F841 # error suppression
- --ignore=F841 # unused-variable
- --ignore=FIX002 # line-contains-to-do
- --ignore=PLR0913 # too-many-arguments
- --ignore=PLR2004 # magic-value-comparison
Expand Down
851 changes: 436 additions & 415 deletions poetry.lock

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pytest-sugar = "^1.0.0"
pandas-stubs = "^2.2.1.240316"
types-networkx = "^3.2.1.20240331"
requests-mock = "^1.12.1"
testcontainers = "^4.4.1"
testcontainers = "4.7.2"
jnussbaum marked this conversation as resolved.
Show resolved Hide resolved
docker = "^7.1.0"
types-docker = "^7.0.0.20240529"
pytest-cov = "^5.0.0"
Expand Down Expand Up @@ -230,4 +230,3 @@ convention = "google"

[tool.ruff.lint.isort]
force-single-line = true
known-first-party = ["dsp_tools"]
jnussbaum marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion src/dsp_tools/commands/excel2json/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def _get_final_series(
case None, None:
return None
case pd.Series(), pd.Series():
final_series = pd.Series(np.logical_or(mandatory_check, no_attribute_check)) # type: ignore[arg-type]
final_series = pd.Series(np.logical_or(mandatory_check, no_attribute_check)) # type: ignore[arg-type, assignment]
case pd.Series(), None:
final_series = mandatory_check # type: ignore[assignment]
case None, pd.Series():
Expand Down
2 changes: 1 addition & 1 deletion test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from dsp_tools.utils.logger_config import logger_config


@pytest.fixture()
@pytest.fixture
jnussbaum marked this conversation as resolved.
Show resolved Hide resolved
def caplog(_caplog: pytest.LogCaptureFixture) -> Iterator[pytest.LogCaptureFixture]: # noqa: F811 (redefinition)
"""
The caplog fixture that comes shipped with pytest does not support loguru.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def mapping_file() -> Iterator[Path]:
mapping_file.unlink(missing_ok=True)


@pytest.fixture()
@pytest.fixture
def _create_project() -> Iterator[None]:
with get_containers():
success = create_project(Path("testdata/json-project/test-project-e2e.json"), CREDS, verbose=True)
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/test_create_and_xmlupload.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,28 @@
RESCLASSES_IN_ONTO_JSON = 2


@pytest.fixture()
@pytest.fixture
def _create_project() -> Iterator[None]:
with get_containers():
success = create_project(Path("testdata/json-project/test-project-e2e.json"), CREDS, verbose=True)
assert success
yield


@pytest.fixture()
@pytest.fixture
def _xmlupload(_create_project: None) -> None:
success = xmlupload(Path("testdata/xml-data/test-data-e2e.xml"), CREDS, ".")
assert success


@pytest.fixture()
@pytest.fixture
def auth_header(_create_project: None) -> dict[str, str]:
payload = {"email": CREDS.user, "password": CREDS.password}
token: str = requests.post(f"{CREDS.server}/v2/authentication", json=payload, timeout=3).json()["token"]
return {"Authorization": f"Bearer {token}"}


@pytest.fixture()
@pytest.fixture
def project_iri(_create_project: None) -> str:
get_project_route = f"{CREDS.server}/admin/projects/shortcode/{PROJECT_SHORTCODE}"
project_iri: str = requests.get(get_project_route, timeout=3).json()["project"]["id"]
Expand Down
2 changes: 1 addition & 1 deletion test/integration/commands/excel2json/test_json_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from dsp_tools.models.exceptions import InputError


@pytest.fixture()
@pytest.fixture
def filled_json_header() -> JsonHeader:
test_path = Path("testdata/excel2json/new_excel2json_files/json_header.xlsx")
return get_json_header(test_path)
Expand Down
4 changes: 2 additions & 2 deletions test/integration/commands/excel2json/test_new_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
from dsp_tools.models.exceptions import InputError


@pytest.fixture()
@pytest.fixture
def result_lists_correct() -> list[dict[str, Any]]:
all_lists, _ = new_excel2lists(Path("testdata/excel2json/new_excel2json_files/lists"))
all_lists = sorted(all_lists, key=lambda x: x["name"])
return all_lists


@pytest.fixture()
@pytest.fixture
def expected_lists() -> list[dict[str, Any]]:
with open("testdata/excel2json/new-lists-output-expected.json", encoding="utf-8") as f:
expected = json.load(f)
Expand Down
4 changes: 2 additions & 2 deletions test/integration/commands/excel2json/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
from dsp_tools.commands.excel2json.project import _validate_folder_structure_get_filenames


@pytest.fixture()
@pytest.fixture
def expected_project() -> dict[str, Any]:
with open("testdata/excel2json/excel2json-expected-output.json", encoding="utf-8") as f:
proj = json.load(f)
return cast(dict[str, Any], proj)


@pytest.fixture()
@pytest.fixture
def returned_project() -> dict[str, Any]:
excel_folder = "testdata/excel2json/excel2json_files"
listfolder, onto_folders = _validate_folder_structure_get_filenames(excel_folder)
Expand Down
2 changes: 1 addition & 1 deletion test/integration/commands/excel2xml/test_excel2xml_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
INVALID_EXCEL_DIRECTORY = "testdata/invalid-testdata/excel2xml"


@pytest.fixture()
@pytest.fixture
def expected_output() -> str:
with open("testdata/excel2xml/excel2xml-expected-output.xml", encoding="utf-8") as f:
return f.read()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def _retrieve_mapping_file() -> Iterator[None]:
Path(mapping_file.name).unlink()


@pytest.fixture()
@pytest.fixture
def creds() -> ServerCredentials:
return ServerCredentials(
user="[email protected]",
Expand Down
6 changes: 3 additions & 3 deletions test/integration/commands/project/test_create_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@
from dsp_tools.utils.shared import parse_json_input


@pytest.fixture()
@pytest.fixture
def tp_systematic() -> dict[str, Any]:
tp_systematic_file = "testdata/json-project/test-project-systematic.json"
with open(tp_systematic_file, encoding="utf-8") as json_file:
tp_systematic: dict[str, Any] = json.load(json_file)
return tp_systematic


@pytest.fixture()
@pytest.fixture
def tp_systematic_ontology(tp_systematic: dict[str, Any]) -> dict[str, Any]:
onto: dict[str, Any] = tp_systematic["project"]["ontologies"][0]
return onto


@pytest.fixture()
@pytest.fixture
def tp_circular_ontology() -> dict[str, Any]:
tp_circular_ontology_file = "testdata/invalid-testdata/json-project/circular-ontology.json"
with open(tp_circular_ontology_file, encoding="utf-8") as json_file:
Expand Down
2 changes: 1 addition & 1 deletion test/integration/commands/project/test_models_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from test.integration.commands.xmlupload.connection_mock import ConnectionMockBase


@pytest.fixture()
@pytest.fixture
def project() -> Project:
return Project(
con=ConnectionMockBase(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from dsp_tools.utils.connection_live import ConnectionLive


@pytest.fixture()
@pytest.fixture
def ingest_client_mock(): # type: ignore[no-untyped-def]
return Mock(spec_set=AssetClient)

Expand Down
4 changes: 2 additions & 2 deletions test/integration/utils/test_xml_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
from dsp_tools.utils.xml_utils import parse_and_clean_xml_file


@pytest.fixture()
@pytest.fixture
def data_systematic_unclean() -> Path:
return Path("testdata/xml-data/test-data-systematic.xml")


@pytest.fixture()
@pytest.fixture
def data_systematic_cleaned() -> etree._Element:
return parse_and_clean_xml_file(Path("testdata/xml-data/test-data-systematic.xml"))

Expand Down
48 changes: 24 additions & 24 deletions test/unittests/commands/excel2json/json_header_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,56 +4,56 @@
import pytest


@pytest.fixture()
@pytest.fixture
def prefixes_good() -> pd.DataFrame:
return pd.DataFrame(
{"prefixes": ["foaf:", "sdh"], "uri": ["http://xmlns.com/foaf/0.1/", "https://ontome.net/ns/sdhss/"]}
)


@pytest.fixture()
@pytest.fixture
def prefixes_missing_col() -> pd.DataFrame:
return pd.DataFrame({"uri": ["http://xmlns.com/foaf/0.1/", "https://ontome.net/ns/sdhss/"]})


@pytest.fixture()
@pytest.fixture
def prefixes_missing_val() -> pd.DataFrame:
return pd.DataFrame(
{"prefixes": ["foaf:", pd.NA], "uri": ["http://xmlns.com/foaf/0.1/", "https://ontome.net/ns/sdhss/"]}
)


@pytest.fixture()
@pytest.fixture
def prefixes_wrong_val() -> pd.DataFrame:
return pd.DataFrame({"prefixes": ["foaf:", "sdh"], "uri": ["http://xmlns.com/foaf/0.1/", "not a uri"]})


@pytest.fixture()
@pytest.fixture
def project_good_missing_zero() -> pd.DataFrame:
return pd.DataFrame({"shortcode": [11], "shortname": ["name"], "longname": ["long"]})


@pytest.fixture()
@pytest.fixture
def project_good_no_zero() -> pd.DataFrame:
return pd.DataFrame({"shortcode": [1111], "shortname": ["name"], "longname": ["long"]})


@pytest.fixture()
@pytest.fixture
def project_missing_col() -> pd.DataFrame:
return pd.DataFrame({"shortname": ["name"], "longname": ["long"]})


@pytest.fixture()
@pytest.fixture
def project_missing_val() -> pd.DataFrame:
return pd.DataFrame({"shortcode": [pd.NA], "shortname": ["name"], "longname": ["long"]})


@pytest.fixture()
@pytest.fixture
def project_too_many_rows() -> pd.DataFrame:
return pd.DataFrame({"shortcode": [11, 0], "shortname": ["name", pd.NA], "longname": ["long", "other"]})


@pytest.fixture()
@pytest.fixture
def description_good() -> pd.DataFrame:
return pd.DataFrame(
{
Expand All @@ -65,7 +65,7 @@ def description_good() -> pd.DataFrame:
)


@pytest.fixture()
@pytest.fixture
def description_too_many_rows() -> pd.DataFrame:
return pd.DataFrame(
{
Expand All @@ -78,32 +78,32 @@ def description_too_many_rows() -> pd.DataFrame:
)


@pytest.fixture()
@pytest.fixture
def description_missing_col() -> pd.DataFrame:
return pd.DataFrame({"other": ["english"]})


@pytest.fixture()
@pytest.fixture
def description_missing_val() -> pd.DataFrame:
return pd.DataFrame({"other": ["english"], "description_en": [pd.NA]})


@pytest.fixture()
@pytest.fixture
def keywords_good() -> pd.DataFrame:
return pd.DataFrame({"keywords": ["one", pd.NA, "three"]})


@pytest.fixture()
@pytest.fixture
def keywords_missing_col() -> pd.DataFrame:
return pd.DataFrame({"other": [1]})


@pytest.fixture()
@pytest.fixture
def keywords_missing_val() -> pd.DataFrame:
return pd.DataFrame({"other": [1], "keywords": [pd.NA]})


@pytest.fixture()
@pytest.fixture
def users_good() -> pd.DataFrame:
return pd.DataFrame(
{
Expand All @@ -118,7 +118,7 @@ def users_good() -> pd.DataFrame:
)


@pytest.fixture()
@pytest.fixture
def users_missing_col() -> pd.DataFrame:
return pd.DataFrame(
{
Expand All @@ -132,7 +132,7 @@ def users_missing_col() -> pd.DataFrame:
)


@pytest.fixture()
@pytest.fixture
def users_missing_val() -> pd.DataFrame:
return pd.DataFrame(
{
Expand All @@ -147,7 +147,7 @@ def users_missing_val() -> pd.DataFrame:
)


@pytest.fixture()
@pytest.fixture
def users_wrong_lang() -> pd.DataFrame:
return pd.DataFrame(
{
Expand All @@ -162,7 +162,7 @@ def users_wrong_lang() -> pd.DataFrame:
)


@pytest.fixture()
@pytest.fixture
def user_good() -> pd.Series[str]:
return pd.Series(
{
Expand All @@ -177,7 +177,7 @@ def user_good() -> pd.Series[str]:
)


@pytest.fixture()
@pytest.fixture
def user_wrong_lang() -> pd.Series[str]:
return pd.Series(
{
Expand All @@ -192,7 +192,7 @@ def user_wrong_lang() -> pd.Series[str]:
)


@pytest.fixture()
@pytest.fixture
def user_wrong_email() -> pd.Series[str]:
return pd.Series(
{
Expand All @@ -207,7 +207,7 @@ def user_wrong_email() -> pd.Series[str]:
)


@pytest.fixture()
@pytest.fixture
def user_wrong_role() -> pd.Series[str]:
return pd.Series(
{
Expand Down
Loading