Skip to content

Commit c35816f

Browse files
authored
Merge pull request #345 from sneakers-the-rat/python-3.13
Add python 3.13, Remove python 3.8
2 parents 4f31524 + d2c7359 commit c35816f

File tree

107 files changed

+2339
-2523
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+2339
-2523
lines changed

.github/workflows/main.yaml

+5-3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ jobs:
1212
fail-fast: false
1313
matrix:
1414
os: [ubuntu-latest, windows-latest]
15-
python-version: ["3.8", "3.9", "3.10", "3.12"]
15+
python-version: ["3.9", "3.10", "3.12", "3.13"]
1616
exclude:
1717
- os: windows-latest
18-
python-version: "3.8"
18+
python-version: "3.10"
19+
- os: windows-latest
20+
python-version: "3.12"
1921

2022
runs-on: ${{ matrix.os }}
2123

@@ -34,7 +36,7 @@ jobs:
3436
uses: actions/checkout@v3
3537

3638
- name: Set up Python ${{ matrix.python-version }}
37-
uses: actions/setup-python@v4
39+
uses: actions/setup-python@v5
3840
with:
3941
python-version: ${{ matrix.python-version }}
4042
cache: 'poetry'

.github/workflows/pypi-publish.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Set up Python
1616
uses: actions/[email protected]
1717
with:
18-
python-version: 3.8
18+
python-version: 3.12
1919

2020
- name: Install Poetry
2121
run: pipx install poetry

.github/workflows/test-upstream.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ jobs:
2020
fail-fast: false
2121
matrix:
2222
os: [ ubuntu-latest, windows-latest ]
23-
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
23+
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]
2424
exclude:
25-
- os: windows-latest
26-
python-version: "3.9"
2725
- os: windows-latest
2826
python-version: "3.10"
2927
- os: windows-latest
3028
python-version: "3.11"
29+
- os: windows-latest
30+
python-version: "3.12"
3131
runs-on: ${{ matrix.os }}
3232
env:
3333
POETRY_VIRTUALENVS_IN_PROJECT: true

linkml_runtime/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
from linkml_runtime.utils.schemaview import SchemaView
44
from rdflib import RDF, RDFS, SKOS, XSD, OWL
55

6+
__all__ = [
7+
"SchemaView",
8+
]
9+
610
# use importlib.metadata to read the version provided
711
# by the package during installation. Do not hardcode
812
# the version in the code

linkml_runtime/dumpers/delimited_file_dumper.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import io
2-
import yaml
32
import json
43
from abc import ABC, abstractmethod
54
from typing import Union
65
from pydantic import BaseModel
6+
from json_flattener import GlobalConfig
77

88
from linkml_runtime.dumpers.dumper_root import Dumper
99
from linkml_runtime.dumpers.json_dumper import JSONDumper
1010
from linkml_runtime.utils.yamlutils import YAMLRoot
1111
from linkml_runtime.linkml_model.meta import SlotDefinitionName, SchemaDefinition
1212
from linkml_runtime.utils.schemaview import SchemaView
1313

14-
from linkml_runtime.utils.csvutils import GlobalConfig, get_configmap
14+
from linkml_runtime.utils.csvutils import get_configmap
1515
from json_flattener import flatten_to_csv
1616

1717

linkml_runtime/dumpers/json_dumper.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import json
22
from datetime import datetime, date
33
from decimal import Decimal
4-
from typing import Dict, Union
4+
from typing import Union
55
from pydantic import BaseModel
66

77
from deprecated.classic import deprecated
@@ -31,7 +31,7 @@ def dump(self, element: Union[BaseModel, YAMLRoot], to_file: str, contexts: CONT
3131
* A list containing elements of any type named above
3232
"""
3333
if isinstance(element, BaseModel):
34-
element = element.dict()
34+
element = element.model_dump()
3535
super().dump(element, to_file, contexts=contexts, **kwargs)
3636

3737
def dumps(self, element: Union[BaseModel, YAMLRoot], contexts: CONTEXTS_PARAM_TYPE = None, inject_type=True) -> str:
@@ -51,7 +51,7 @@ def dumps(self, element: Union[BaseModel, YAMLRoot], contexts: CONTEXTS_PARAM_TY
5151

5252
def default(o):
5353
if isinstance(o, BaseModel):
54-
return remove_empty_items(o.dict(), hide_protected_keys=True)
54+
return remove_empty_items(o.model_dump(), hide_protected_keys=True)
5555
if isinstance(o, YAMLRoot):
5656
return remove_empty_items(o, hide_protected_keys=True)
5757
elif isinstance(o, Decimal):
@@ -62,15 +62,15 @@ def default(o):
6262
else:
6363
return json.JSONDecoder().decode(o)
6464
if isinstance(element, BaseModel):
65-
element = element.dict()
65+
element = element.model_dump()
6666
return json.dumps(as_json_object(element, contexts, inject_type=inject_type),
6767
default=default,
6868
ensure_ascii=False,
6969
indent=' ')
7070

7171
@staticmethod
7272
@deprecated("Use `utils/formatutils/remove_empty_items` instead")
73-
def remove_empty_items(obj: Dict) -> Dict:
73+
def remove_empty_items(obj: dict) -> dict:
7474
"""
7575
Remove empty items from obj
7676
:param obj:

linkml_runtime/dumpers/rdf_dumper.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def dump(self, element: Union[BaseModel, YAMLRoot], to_file: str, contexts: CONT
7979
:param fmt: RDF format
8080
"""
8181
if isinstance(element, BaseModel):
82-
element = element.dict()
82+
element = element.model_dump()
8383
super().dump(element, to_file, contexts=contexts, fmt=fmt)
8484

8585
def dumps(self, element: Union[BaseModel, YAMLRoot], contexts: CONTEXTS_PARAM_TYPE = None, fmt: Optional[str] = 'turtle') -> str:
@@ -91,6 +91,6 @@ def dumps(self, element: Union[BaseModel, YAMLRoot], contexts: CONTEXTS_PARAM_TY
9191
:return: rdflib Graph containing element
9292
"""
9393
if isinstance(element, BaseModel):
94-
element = element.dict()
94+
element = element.model_dump()
9595
return self.as_rdf_graph(remove_empty_items(element, hide_protected_keys=True), contexts).\
9696
serialize(format=fmt)

linkml_runtime/dumpers/rdflib_dumper.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import logging
22
import urllib
3-
from abc import abstractmethod
4-
from typing import Optional, Any, Dict, Union
3+
from typing import Optional, Any, Union
54
from pydantic import BaseModel
65

76
from curies import Converter
@@ -31,7 +30,7 @@ def as_rdf_graph(
3130
self,
3231
element: Union[BaseModel, YAMLRoot],
3332
schemaview: SchemaView,
34-
prefix_map: Union[Dict[str, str], Converter, None] = None,
33+
prefix_map: Union[dict[str, str], Converter, None] = None,
3534
) -> Graph:
3635
"""
3736
Dumps from element to an rdflib Graph,
@@ -154,7 +153,7 @@ def dump(
154153
to_file: str,
155154
schemaview: SchemaView = None,
156155
fmt: str = 'turtle',
157-
prefix_map: Union[Dict[str, str], Converter, None] = None,
156+
prefix_map: Union[dict[str, str], Converter, None] = None,
158157
**args,
159158
) -> None:
160159
"""
@@ -174,7 +173,7 @@ def dumps(
174173
element: Union[BaseModel, YAMLRoot],
175174
schemaview: SchemaView = None,
176175
fmt: Optional[str] = 'turtle',
177-
prefix_map: Union[Dict[str, str], Converter, None] = None,
176+
prefix_map: Union[dict[str, str], Converter, None] = None,
178177
) -> str:
179178
"""
180179
Convert element into an RDF graph guided by the schema

linkml_runtime/index/object_index.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"""
1111
import logging
1212
import inspect
13-
from typing import Mapping, Any, Optional, Tuple, List, Iterator, Union
13+
from typing import Any, Union
14+
from collections.abc import Mapping, Iterator
1415

1516
from linkml_runtime import SchemaView
1617
from linkml_runtime.utils import eval_utils
@@ -54,8 +55,8 @@ def __init__(self, obj: YAMLRoot, schemaview: SchemaView):
5455
self._schemaview = schemaview
5556
self._class_map = schemaview.class_name_mappings()
5657
self._source_object_cache: Mapping[str, Any] = {}
57-
self._proxy_object_cache: Mapping[str, "ProxyObject"] = {}
58-
self._child_to_parent: Mapping[str, List[Tuple[str, str]]] = {}
58+
self._proxy_object_cache: Mapping[str, ProxyObject] = {}
59+
self._child_to_parent: Mapping[str, list[tuple[str, str]]] = {}
5960
self._index(obj)
6061

6162
def _index(self, obj: Any, parent_key=None, parent=None):
@@ -112,7 +113,7 @@ def bless(self, obj: Any) -> "ProxyObject":
112113
else:
113114
return ProxyObject(obj, _db=self)
114115

115-
def _key(self, obj: Any) -> Tuple[Union[str, YAMLRoot], str]:
116+
def _key(self, obj: Any) -> tuple[Union[str, YAMLRoot], str]:
116117
"""
117118
Returns primary key value for this object.
118119
@@ -265,6 +266,6 @@ def _map(self, obj: Any, in_range: str) -> Any:
265266
return cls(obj)
266267
return obj
267268

268-
def _attributes(self) -> List[str]:
269+
def _attributes(self) -> list[str]:
269270
return list(vars(self._shadowed).keys())
270271

linkml_runtime/linkml_model/__init__.py

+46
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,49 @@
88
Definition, EnumDefinition, SlotDefinition, ClassDefinition, Prefix, LocalName, Example, AltDescription, \
99
PermissibleValue, PvFormulaOptions
1010

11+
__all__ = [
12+
"String",
13+
"Integer",
14+
"Boolean",
15+
"Float",
16+
"Double",
17+
"Decimal",
18+
"Time",
19+
"Date",
20+
"Datetime",
21+
"Uriorcurie",
22+
"Uri",
23+
"Ncname",
24+
"Objectidentifier",
25+
"Nodeidentifier",
26+
"Extension",
27+
"Extensible",
28+
"Annotation",
29+
"Annotatable",
30+
"ElementName",
31+
"SchemaDefinitionName",
32+
"TypeDefinitionName",
33+
"SubsetDefinitionName",
34+
"DefinitionName",
35+
"EnumDefinitionName",
36+
"SlotDefinitionName",
37+
"ClassDefinitionName",
38+
"PrefixPrefixPrefix",
39+
"LocalNameLocalNameSource",
40+
"AltDescriptionSource",
41+
"PermissibleValueText",
42+
"Element",
43+
"SchemaDefinition",
44+
"TypeDefinition",
45+
"SubsetDefinition",
46+
"Definition",
47+
"EnumDefinition",
48+
"SlotDefinition",
49+
"ClassDefinition",
50+
"Prefix",
51+
"LocalName",
52+
"Example",
53+
"AltDescription",
54+
"PermissibleValue",
55+
"PvFormulaOptions",
56+
]

linkml_runtime/linkml_model/annotations.py

+11-22
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,19 @@
66
# description: Annotations mixin
77
# license: https://creativecommons.org/publicdomain/zero/1.0/
88

9-
import dataclasses
10-
import re
11-
from jsonasobj2 import JsonObj, as_dict
12-
from typing import Optional, List, Union, Dict, ClassVar, Any
9+
from typing import Optional, Union, ClassVar, Any
1310
from dataclasses import dataclass
1411

1512
from linkml_runtime.utils.slot import Slot
16-
from linkml_runtime.utils.metamodelcore import empty_list, empty_dict, bnode
17-
from linkml_runtime.utils.yamlutils import YAMLRoot, extended_str, extended_float, extended_int
18-
from linkml_runtime.utils.dataclass_extensions_376 import dataclasses_init_fn_with_kwargs
19-
from linkml_runtime.utils.formatutils import camelcase, underscore, sfx
20-
from linkml_runtime.utils.enumerations import EnumDefinitionImpl
21-
from rdflib import Namespace, URIRef
13+
from linkml_runtime.utils.metamodelcore import empty_dict
14+
from linkml_runtime.utils.yamlutils import YAMLRoot
15+
from rdflib import URIRef
2216
from linkml_runtime.utils.curienamespace import CurieNamespace
2317
from .extensions import AnyValue, Extension, ExtensionTag
24-
from .types import Uriorcurie
25-
from linkml_runtime.utils.metamodelcore import URIorCURIE
2618

2719
metamodel_version = "1.7.0"
2820
version = "2.0.0"
2921

30-
# Overwrite dataclasses _init_fn to add **kwargs in __init__
31-
dataclasses._init_fn = dataclasses_init_fn_with_kwargs
32-
3322
# Namespaces
3423
LINKML = CurieNamespace('linkml', 'https://w3id.org/linkml/')
3524
DEFAULT_ = LINKML
@@ -47,16 +36,16 @@ class Annotatable(YAMLRoot):
4736
"""
4837
mixin for classes that support annotations
4938
"""
50-
_inherited_slots: ClassVar[List[str]] = []
39+
_inherited_slots: ClassVar[list[str]] = []
5140

5241
class_class_uri: ClassVar[URIRef] = LINKML["Annotatable"]
5342
class_class_curie: ClassVar[str] = "linkml:Annotatable"
5443
class_name: ClassVar[str] = "annotatable"
5544
class_model_uri: ClassVar[URIRef] = LINKML.Annotatable
5645

57-
annotations: Optional[Union[Dict[Union[str, AnnotationTag], Union[dict, "Annotation"]], List[Union[dict, "Annotation"]]]] = empty_dict()
46+
annotations: Optional[Union[dict[Union[str, AnnotationTag], Union[dict, "Annotation"]], list[Union[dict, "Annotation"]]]] = empty_dict()
5847

59-
def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
48+
def __post_init__(self, *_: list[str], **kwargs: dict[str, Any]):
6049
self._normalize_inlined_as_dict(slot_name="annotations", slot_type=Annotation, key_name="tag", keyed=True)
6150

6251
super().__post_init__(**kwargs)
@@ -67,7 +56,7 @@ class Annotation(Extension):
6756
"""
6857
a tag/value pair with the semantics of OWL Annotation
6958
"""
70-
_inherited_slots: ClassVar[List[str]] = []
59+
_inherited_slots: ClassVar[list[str]] = []
7160

7261
class_class_uri: ClassVar[URIRef] = LINKML["Annotation"]
7362
class_class_curie: ClassVar[str] = "linkml:Annotation"
@@ -76,9 +65,9 @@ class Annotation(Extension):
7665

7766
tag: Union[str, AnnotationTag] = None
7867
value: Union[dict, AnyValue] = None
79-
annotations: Optional[Union[Dict[Union[str, AnnotationTag], Union[dict, "Annotation"]], List[Union[dict, "Annotation"]]]] = empty_dict()
68+
annotations: Optional[Union[dict[Union[str, AnnotationTag], Union[dict, "Annotation"]], list[Union[dict, "Annotation"]]]] = empty_dict()
8069

81-
def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
70+
def __post_init__(self, *_: list[str], **kwargs: dict[str, Any]):
8271
if self._is_empty(self.tag):
8372
self.MissingRequiredField("tag")
8473
if not isinstance(self.tag, AnnotationTag):
@@ -97,4 +86,4 @@ class slots:
9786
pass
9887

9988
slots.annotations = Slot(uri=LINKML.annotations, name="annotations", curie=LINKML.curie('annotations'),
100-
model_uri=LINKML.annotations, domain=None, range=Optional[Union[Dict[Union[str, AnnotationTag], Union[dict, "Annotation"]], List[Union[dict, "Annotation"]]]])
89+
model_uri=LINKML.annotations, domain=None, range=Optional[Union[dict[Union[str, AnnotationTag], Union[dict, "Annotation"]], list[Union[dict, "Annotation"]]]])

0 commit comments

Comments
 (0)