8000 Automatic ruff lint fixes, plus some type additions and docs. by ialarmedalien · Pull Request #58 · linkml/linkml-map · GitHub
[go: up one dir, main page]

Skip to content

Automatic ruff lint fixes, plus some type additions and docs.#58

Merged
ialarmedalien merged 1 commit intomainfrom
ruff_lint_autofixes_tests
Apr 23, 2025
Merged

Automatic ruff lint fixes, plus some type additions and docs.#58
ialarmedalien merged 1 commit intomainfrom
ruff_lint_autofixes_tests

Conversation

@ialarmedalien
Copy link
Collaborator

More ruff autofixes, plus some extra typing and docs to appease the pydocstyle gods.

print("Target DDL:")
print(target_ddl)

import duckdb
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to top of file

Comment on lines +136 to +137
invertible: bool = False, # noqa: FBT001, FBT002
index: bool = False, # noqa: FBT001, FBT002
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one of the linters gets in a tizzy if you have boolean arguments, so turning off warnings here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing that it wants to see them as keyword-only arguments? I do like that style, but I'm not opposed to ignoring it for now.

Comment on lines +252 to +253
msg = f"Test {node.originalname} has no docstring"
raise AssertionError(msg)
Copy link
Collaborator Author
@ialarmedalien ialarmedalien Apr 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

separate out the error message interpolation/composition from the raise statement, call the error using a variable


@pytest.mark.parametrize(
"source_datatype,target_datatype,source_value,target_value,invertible",
("source_datatype", "target_datatype", "source_value", "target_value", "invertible"),
Copy link
Collaborator Author
@ialarmedalien ialarmedalien Apr 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preferred way to name variables in pytest parametrize

typ = v["type"]
else:
typ = "D"
typ = v.get("type", "D")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use get's default instead of the if/else

f"Class '{schema_class}' is missing in target"
)
assert "Agent" in target_schema.classes.keys(), "Derived class 'Agent' is missing in target"
for schema_class in source_schema.classes:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for .keys() when iterating through dict keys

f"Class '{schema_class}' is missing in target"
)
assert "Agent" in target_schema.classes.keys(), "Derived class 'Agent' is missing in target"
for schema_class in source_schema.classes:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for .keys()

target_schema = mapper.derive_schema(specification)
# classes must be the same with addition
for schema_class in source_schema.classes.keys():
for schema_class in source_schema.classes:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more lost .keys()

schema_url = "https://raw.githubusercontent.com/biolink/biolink-model/master/biolink-model.yaml"
sv = SchemaView(schema_url)
return sv
return SchemaView(schema_url)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

x = obj_tr._coerce_datatype("5", "integer")
def test_coerce(obj_tr: ObjectTransformer) -> None:
"""Test datatype coercion."""
x = obj_tr._coerce_datatype("5", "integer") # noqa: SLF001
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tell ruff that it's OK to reference a private function (._coerce_datatype())

Comment on lines +136 to +137
invertible: bool = False, # noqa: FBT001, FBT002
index: bool = False, # noqa: FBT001, FBT002
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing that it wants to see them as keyword-only arguments? I do like that style, but I'm not opposed to ignoring it for now.

@ialarmedalien ialarmedalien merged commit cd562ae into main Apr 23, 2025
7 checks passed
@ialarmedalien ialarmedalien deleted the ruff_lint_autofixes_tests branch April 23, 2025 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0