Skip to content

Commit

Permalink
linted
Browse files Browse the repository at this point in the history
  • Loading branch information
hrshdhgd committed Feb 17, 2024
1 parent 6a37e68 commit 15bf85c
Show file tree
Hide file tree
Showing 53 changed files with 218 additions and 169 deletions.
1 change: 1 addition & 0 deletions src/oaklib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Oaklib
------
"""

__version__ = "0.1.0"

from oaklib.interfaces import BasicOntologyInterface # noqa:F401
Expand Down
1 change: 1 addition & 0 deletions src/oaklib/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Executed using "runoak" command
"""

# TODO: order commands.
# See https://stackoverflow.com/questions/47972638/how-can-i-define-the-order-of-click-sub-commands-in-help
import itertools
Expand Down
1 change: 1 addition & 0 deletions src/oaklib/converters/obo_graph_to_fhir_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- Updates issue: https://github.com/INCATools/ontology-access-kit/issues/369
- Conversion examples: https://drive.google.com/drive/folders/1lwGQ63_fedfWlGlRemq8OeZhZsvIXN01
"""

import logging
from dataclasses import dataclass
from typing import Any, Dict, List, Tuple, Union
Expand Down
48 changes: 24 additions & 24 deletions src/oaklib/datamodels/association.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,22 @@ class PositiveOrNegativeAssociation(YAMLRoot):
predicate_label: Optional[str] = None
object_label: Optional[str] = None
negated: Optional[Union[bool, Bool]] = None
publications: Optional[
Union[Union[str, URIorCURIE], List[Union[str, URIorCURIE]]]
] = empty_list()
publications: Optional[Union[Union[str, URIorCURIE], List[Union[str, URIorCURIE]]]] = (
empty_list()
)
evidence_type: Optional[Union[str, URIorCURIE]] = None
supporting_objects: Optional[
Union[Union[str, URIorCURIE], List[Union[str, URIorCURIE]]]
] = empty_list()
supporting_objects: Optional[Union[Union[str, URIorCURIE], List[Union[str, URIorCURIE]]]] = (
empty_list()
)
primary_knowledge_source: Optional[Union[str, URIorCURIE]] = None
aggregator_knowledge_source: Optional[Union[str, URIorCURIE]] = None
subject_closure: Optional[
Union[Union[str, URIorCURIE], List[Union[str, URIorCURIE]]]
] = empty_list()
subject_closure: Optional[Union[Union[str, URIorCURIE], List[Union[str, URIorCURIE]]]] = (
empty_list()
)
subject_closure_label: Optional[Union[str, List[str]]] = empty_list()
object_closure: Optional[
Union[Union[str, URIorCURIE], List[Union[str, URIorCURIE]]]
] = empty_list()
object_closure: Optional[Union[Union[str, URIorCURIE], List[Union[str, URIorCURIE]]]] = (
empty_list()
)
object_closure_label: Optional[Union[str, List[str]]] = empty_list()
comments: Optional[Union[str, List[str]]] = empty_list()

Expand Down Expand Up @@ -292,12 +292,12 @@ class RollupGroup(YAMLRoot):
class_model_uri: ClassVar[URIRef] = ONTOASSOC.RollupGroup

group_object: Optional[Union[str, URIorCURIE]] = None
sub_groups: Optional[
Union[Union[dict, "RollupGroup"], List[Union[dict, "RollupGroup"]]]
] = empty_list()
associations: Optional[
Union[Union[dict, Association], List[Union[dict, Association]]]
] = empty_list()
sub_groups: Optional[Union[Union[dict, "RollupGroup"], List[Union[dict, "RollupGroup"]]]] = (
empty_list()
)
associations: Optional[Union[Union[dict, Association], List[Union[dict, Association]]]] = (
empty_list()
)

def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
if self.group_object is not None and not isinstance(self.group_object, URIorCURIE):
Expand Down Expand Up @@ -458,9 +458,9 @@ class AssociationChange(YAMLRoot):
new_date: Optional[str] = None
primary_knowledge_source: Optional[Union[str, URIorCURIE]] = None
aggregator_knowledge_source: Optional[Union[str, URIorCURIE]] = None
publications: Optional[
Union[Union[str, URIorCURIE], List[Union[str, URIorCURIE]]]
] = empty_list()
publications: Optional[Union[Union[str, URIorCURIE], List[Union[str, URIorCURIE]]]] = (
empty_list()
)
publication_is_added: Optional[Union[bool, Bool]] = None
publication_is_deleted: Optional[Union[bool, Bool]] = None
subject: Optional[Union[str, URIorCURIE]] = None
Expand All @@ -474,9 +474,9 @@ class AssociationChange(YAMLRoot):
is_specialization: Optional[Union[bool, Bool]] = None
is_creation: Optional[Union[bool, Bool]] = None
is_deletion: Optional[Union[bool, Bool]] = None
closure_predicates: Optional[
Union[Union[str, URIorCURIE], List[Union[str, URIorCURIE]]]
] = empty_list()
closure_predicates: Optional[Union[Union[str, URIorCURIE], List[Union[str, URIorCURIE]]]] = (
empty_list()
)
closure_delta: Optional[int] = None

def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
Expand Down
12 changes: 6 additions & 6 deletions src/oaklib/datamodels/cross_ontology_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ class StructureDiffResultSet(YAMLRoot):
class_name: ClassVar[str] = "StructureDiffResultSet"
class_model_uri: ClassVar[URIRef] = XODIFF.StructureDiffResultSet

results: Optional[
Union[Union[dict, "RelationalDiff"], List[Union[dict, "RelationalDiff"]]]
] = empty_list()
results: Optional[Union[Union[dict, "RelationalDiff"], List[Union[dict, "RelationalDiff"]]]] = (
empty_list()
)
left_source: Optional[Union[str, Source]] = None
right_source: Optional[Union[str, Source]] = None

Expand Down Expand Up @@ -180,9 +180,9 @@ class RelationalDiff(YAMLRoot):
] = empty_list()
right_subject_label: Optional[Union[str, Label]] = None
right_object_label: Optional[Union[str, Label]] = None
right_predicate_labels: Optional[
Union[Union[str, Label], List[Union[str, Label]]]
] = empty_list()
right_predicate_labels: Optional[Union[Union[str, Label], List[Union[str, Label]]]] = (
empty_list()
)
left_subject_is_functional: Optional[str] = None
left_object_is_functional: Optional[str] = None
subject_mapping_predicate: Optional[Union[str, EntityReference]] = None
Expand Down
6 changes: 3 additions & 3 deletions src/oaklib/datamodels/fhir.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,9 @@ class ConceptMap(YAMLRoot):
sourceCanonical: Optional[Union[str, URIorCURIE]] = None
targetUri: Optional[Union[str, URIorCURIE]] = None
targetCanonical: Optional[Union[str, URIorCURIE]] = None
group: Optional[
Union[Union[dict, "ConceptMapGroup"], List[Union[dict, "ConceptMapGroup"]]]
] = empty_list()
group: Optional[Union[Union[dict, "ConceptMapGroup"], List[Union[dict, "ConceptMapGroup"]]]] = (
empty_list()
)

def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
if self.id is not None and not isinstance(self.id, str):
Expand Down
6 changes: 3 additions & 3 deletions src/oaklib/datamodels/input_specification.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ class AssociationResource(Resource):
class_model_uri: ClassVar[URIRef] = ITEMLIST.AssociationResource

id: Union[str, AssociationResourceId] = None
normalizers: Optional[
Union[Union[dict, "Normalizer"], List[Union[dict, "Normalizer"]]]
] = empty_list()
normalizers: Optional[Union[Union[dict, "Normalizer"], List[Union[dict, "Normalizer"]]]] = (
empty_list()
)

def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
if self._is_empty(self.id):
Expand Down
24 changes: 12 additions & 12 deletions src/oaklib/datamodels/item_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ class ItemListCollection(YAMLRoot):
class_name: ClassVar[str] = "ItemListCollection"
class_model_uri: ClassVar[URIRef] = ITEMLIST.ItemListCollection

itemLists: Optional[
Union[Union[dict, "ItemList"], List[Union[dict, "ItemList"]]]
] = empty_list()
itemLists: Optional[Union[Union[dict, "ItemList"], List[Union[dict, "ItemList"]]]] = (
empty_list()
)

def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
if not isinstance(self.itemLists, list):
Expand Down Expand Up @@ -126,12 +126,12 @@ class ItemList(YAMLRoot):
] = empty_dict()
categories: Optional[Union[Union[str, URIorCURIE], List[Union[str, URIorCURIE]]]] = empty_list()
keywords: Optional[Union[str, List[str]]] = empty_list()
additionalType: Optional[
Union[Union[str, URIorCURIE], List[Union[str, URIorCURIE]]]
] = empty_list()
wasGeneratedBy: Optional[
Union[Union[str, URIorCURIE], List[Union[str, URIorCURIE]]]
] = empty_list()
additionalType: Optional[Union[Union[str, URIorCURIE], List[Union[str, URIorCURIE]]]] = (
empty_list()
)
wasGeneratedBy: Optional[Union[Union[str, URIorCURIE], List[Union[str, URIorCURIE]]]] = (
empty_list()
)

def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
if self.id is not None and not isinstance(self.id, URIorCURIE):
Expand Down Expand Up @@ -236,9 +236,9 @@ class Thing(YAMLRoot):
id: Union[str, ThingId] = None
name: Optional[str] = None
url: Optional[Union[str, URI]] = None
identifiers: Optional[
Union[Union[str, URIorCURIE], List[Union[str, URIorCURIE]]]
] = empty_list()
identifiers: Optional[Union[Union[str, URIorCURIE], List[Union[str, URIorCURIE]]]] = (
empty_list()
)
description: Optional[str] = None
type: Optional[Union[str, URIorCURIE]] = None

Expand Down
8 changes: 5 additions & 3 deletions src/oaklib/datamodels/lexical_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,11 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
if not isinstance(self.pipeline, list):
self.pipeline = [self.pipeline] if self.pipeline is not None else []
self.pipeline = [
v
if isinstance(v, LexicalTransformationPipelineName)
else LexicalTransformationPipelineName(v)
(
v
if isinstance(v, LexicalTransformationPipelineName)
else LexicalTransformationPipelineName(v)
)
for v in self.pipeline
]

Expand Down
8 changes: 5 additions & 3 deletions src/oaklib/datamodels/mapping_cluster_datamodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,11 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
[self.predicate_probabilities] if self.predicate_probabilities is not None else []
)
self.predicate_probabilities = [
v
if isinstance(v, PredicateProbabilityPredicateId)
else PredicateProbabilityPredicateId(v)
(
v
if isinstance(v, PredicateProbabilityPredicateId)
else PredicateProbabilityPredicateId(v)
)
for v in self.predicate_probabilities
]

Expand Down
14 changes: 8 additions & 6 deletions src/oaklib/datamodels/mapping_rules_datamodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ class MappingRuleCollection(YAMLRoot):
class_name: ClassVar[str] = "MappingRuleCollection"
class_model_uri: ClassVar[URIRef] = MAPPINGRULES.MappingRuleCollection

rules: Optional[
Union[Union[dict, "MappingRule"], List[Union[dict, "MappingRule"]]]
] = empty_list()
rules: Optional[Union[Union[dict, "MappingRule"], List[Union[dict, "MappingRule"]]]] = (
empty_list()
)
minimum_confidence: Optional[float] = None

def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
Expand Down Expand Up @@ -440,9 +440,11 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
if not isinstance(self.pipeline, list):
self.pipeline = [self.pipeline] if self.pipeline is not None else []
self.pipeline = [
v
if isinstance(v, LexicalTransformationPipelineName)
else LexicalTransformationPipelineName(v)
(
v
if isinstance(v, LexicalTransformationPipelineName)
else LexicalTransformationPipelineName(v)
)
for v in self.pipeline
]

Expand Down
22 changes: 13 additions & 9 deletions src/oaklib/datamodels/obograph.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ class Graph(YAMLRoot):
domainRangeAxioms: Optional[
Union[Union[dict, "DomainRangeAxiom"], List[Union[dict, "DomainRangeAxiom"]]]
] = empty_list()
allValuesFromEdges: Optional[
Union[Union[dict, "Edge"], List[Union[dict, "Edge"]]]
] = empty_list()
allValuesFromEdges: Optional[Union[Union[dict, "Edge"], List[Union[dict, "Edge"]]]] = (
empty_list()
)
propertyChainAxioms: Optional[
Union[Union[dict, "PropertyChainAxiom"], List[Union[dict, "PropertyChainAxiom"]]]
] = empty_list()
Expand Down Expand Up @@ -805,9 +805,11 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
if not isinstance(self.restrictions, list):
self.restrictions = [self.restrictions] if self.restrictions is not None else []
self.restrictions = [
v
if isinstance(v, ExistentialRestrictionExpression)
else ExistentialRestrictionExpression(**as_dict(v))
(
v
if isinstance(v, ExistentialRestrictionExpression)
else ExistentialRestrictionExpression(**as_dict(v))
)
for v in self.restrictions
]

Expand Down Expand Up @@ -848,9 +850,11 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
[self.classExpressions] if self.classExpressions is not None else []
)
self.classExpressions = [
v
if isinstance(v, ExistentialRestrictionExpression)
else ExistentialRestrictionExpression(**as_dict(v))
(
v
if isinstance(v, ExistentialRestrictionExpression)
else ExistentialRestrictionExpression(**as_dict(v))
)
for v in self.classExpressions
]

Expand Down
Loading

0 comments on commit 15bf85c

Please sign in to comment.