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

Add python 3.13, Remove python 3.8 #345

Merged
merged 24 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
902c798
python 3.13 update
sneakers-the-rat Oct 9, 2024
ca9397c
dang i guess ruff really just failed at that check and also removed a…
sneakers-the-rat Oct 9, 2024
6eef0f5
rm dataclass monkeypatch for kwargs in init
sneakers-the-rat Oct 14, 2024
43b3b3d
rm from imports in test cases and modules, rm redundant 718a test, xf…
sneakers-the-rat Oct 14, 2024
4c08b68
rm deprecated pydantic calls for what feels like the one thousandth time
sneakers-the-rat Oct 14, 2024
50f5564
rm block marked as to be deprecated with python 3.7 but without depre…
sneakers-the-rat Oct 15, 2024
761957c
don't discover TestEnvironment as being itself a test
sneakers-the-rat Oct 15, 2024
7220772
python 3.9 compat
sneakers-the-rat Oct 15, 2024
47df18b
rm pdb
sneakers-the-rat Oct 28, 2024
c6e5e14
Update pyproject.toml
sneakers-the-rat Jan 24, 2025
e495067
fix text upstream by allowing an incorrectly low version of python fo…
sneakers-the-rat Feb 1, 2025
6c849d9
catch new old-style type annotations, no second-order import of Globa…
sneakers-the-rat Feb 27, 2025
2892e08
a line
sneakers-the-rat Feb 27, 2025
3c4052a
no-op to trigger upstream tests
sneakers-the-rat Feb 27, 2025
d32aaab
revert no-op
sneakers-the-rat Feb 27, 2025
9ff878a
update lockfile to rescue pydantic 2.10.4 fix from upstream
sneakers-the-rat Feb 27, 2025
2a8a08d
add isodate as an explicit dependency
sneakers-the-rat Feb 27, 2025
9414aaf
Merge branch 'main' into python-3.13
amc-corey-cox Mar 18, 2025
43318c8
no op
sneakers-the-rat Mar 27, 2025
892d1ac
revert no op
sneakers-the-rat Mar 27, 2025
8184d01
no op again
sneakers-the-rat Mar 27, 2025
57751b5
revert no op again
sneakers-the-rat Mar 27, 2025
17391e5
no op a third time
sneakers-the-rat Mar 27, 2025
d2c7359
revert no op a third time
sneakers-the-rat Mar 27, 2025
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
8 changes: 5 additions & 3 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.12"]
python-version: ["3.9", "3.10", "3.12", "3.13"]
exclude:
- os: windows-latest
python-version: "3.8"
python-version: "3.10"
- os: windows-latest
python-version: "3.12"

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

Expand All @@ -34,7 +36,7 @@ jobs:
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pypi-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Set up Python
uses: actions/[email protected]
with:
python-version: 3.8
python-version: 3.12

- name: Install Poetry
run: pipx install poetry
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test-upstream.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ jobs:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest ]
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]
exclude:
- os: windows-latest
python-version: "3.9"
- os: windows-latest
python-version: "3.10"
- os: windows-latest
python-version: "3.11"
- os: windows-latest
python-version: "3.12"
runs-on: ${{ matrix.os }}
env:
POETRY_VIRTUALENVS_IN_PROJECT: true
Expand Down
4 changes: 4 additions & 0 deletions linkml_runtime/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
from linkml_runtime.utils.schemaview import SchemaView
from rdflib import RDF, RDFS, SKOS, XSD, OWL

__all__ = [
"SchemaView",
]

# use importlib.metadata to read the version provided
# by the package during installation. Do not hardcode
# the version in the code
Expand Down
4 changes: 2 additions & 2 deletions linkml_runtime/dumpers/delimited_file_dumper.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import io
import yaml
import json
from abc import ABC, abstractmethod
from typing import Union
from pydantic import BaseModel
from json_flattener import GlobalConfig

from linkml_runtime.dumpers.dumper_root import Dumper
from linkml_runtime.dumpers.json_dumper import JSONDumper
from linkml_runtime.utils.yamlutils import YAMLRoot
from linkml_runtime.linkml_model.meta import SlotDefinitionName, SchemaDefinition
from linkml_runtime.utils.schemaview import SchemaView

from linkml_runtime.utils.csvutils import GlobalConfig, get_configmap
from linkml_runtime.utils.csvutils import get_configmap
from json_flattener import flatten_to_csv


Expand Down
10 changes: 5 additions & 5 deletions linkml_runtime/dumpers/json_dumper.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
from datetime import datetime, date
from decimal import Decimal
from typing import Dict, Union
from typing import Union
from pydantic import BaseModel

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

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

def default(o):
if isinstance(o, BaseModel):
return remove_empty_items(o.dict(), hide_protected_keys=True)
return remove_empty_items(o.model_dump(), hide_protected_keys=True)
if isinstance(o, YAMLRoot):
return remove_empty_items(o, hide_protected_keys=True)
elif isinstance(o, Decimal):
Expand All @@ -62,15 +62,15 @@ def default(o):
else:
return json.JSONDecoder().decode(o)
if isinstance(element, BaseModel):
element = element.dict()
element = element.model_dump()
return json.dumps(as_json_object(element, contexts, inject_type=inject_type),
default=default,
ensure_ascii=False,
indent=' ')

@staticmethod
@deprecated("Use `utils/formatutils/remove_empty_items` instead")
def remove_empty_items(obj: Dict) -> Dict:
def remove_empty_items(obj: dict) -> dict:
"""
Remove empty items from obj
:param obj:
Expand Down
4 changes: 2 additions & 2 deletions linkml_runtime/dumpers/rdf_dumper.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def dump(self, element: Union[BaseModel, YAMLRoot], to_file: str, contexts: CONT
:param fmt: RDF format
"""
if isinstance(element, BaseModel):
element = element.dict()
element = element.model_dump()
super().dump(element, to_file, contexts=contexts, fmt=fmt)

def dumps(self, element: Union[BaseModel, YAMLRoot], contexts: CONTEXTS_PARAM_TYPE = None, fmt: Optional[str] = 'turtle') -> str:
Expand All @@ -91,6 +91,6 @@ def dumps(self, element: Union[BaseModel, YAMLRoot], contexts: CONTEXTS_PARAM_TY
:return: rdflib Graph containing element
"""
if isinstance(element, BaseModel):
element = element.dict()
element = element.model_dump()
return self.as_rdf_graph(remove_empty_items(element, hide_protected_keys=True), contexts).\
serialize(format=fmt)
9 changes: 4 additions & 5 deletions linkml_runtime/dumpers/rdflib_dumper.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import logging
import urllib
from abc import abstractmethod
from typing import Optional, Any, Dict, Union
from typing import Optional, Any, Union
from pydantic import BaseModel

from curies import Converter
Expand Down Expand Up @@ -31,7 +30,7 @@ def as_rdf_graph(
self,
element: Union[BaseModel, YAMLRoot],
schemaview: SchemaView,
prefix_map: Union[Dict[str, str], Converter, None] = None,
prefix_map: Union[dict[str, str], Converter, None] = None,
) -> Graph:
"""
Dumps from element to an rdflib Graph,
Expand Down Expand Up @@ -154,7 +153,7 @@ def dump(
to_file: str,
schemaview: SchemaView = None,
fmt: str = 'turtle',
prefix_map: Union[Dict[str, str], Converter, None] = None,
prefix_map: Union[dict[str, str], Converter, None] = None,
**args,
) -> None:
"""
Expand All @@ -174,7 +173,7 @@ def dumps(
element: Union[BaseModel, YAMLRoot],
schemaview: SchemaView = None,
fmt: Optional[str] = 'turtle',
prefix_map: Union[Dict[str, str], Converter, None] = None,
prefix_map: Union[dict[str, str], Converter, None] = None,
) -> str:
"""
Convert element into an RDF graph guided by the schema
Expand Down
11 changes: 6 additions & 5 deletions linkml_runtime/index/object_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"""
import logging
import inspect
from typing import Mapping, Any, Optional, Tuple, List, Iterator, Union
from typing import Any, Union
from collections.abc import Mapping, Iterator

from linkml_runtime import SchemaView
from linkml_runtime.utils import eval_utils
Expand Down Expand Up @@ -54,8 +55,8 @@ def __init__(self, obj: YAMLRoot, schemaview: SchemaView):
self._schemaview = schemaview
self._class_map = schemaview.class_name_mappings()
self._source_object_cache: Mapping[str, Any] = {}
self._proxy_object_cache: Mapping[str, "ProxyObject"] = {}
self._child_to_parent: Mapping[str, List[Tuple[str, str]]] = {}
self._proxy_object_cache: Mapping[str, ProxyObject] = {}
self._child_to_parent: Mapping[str, list[tuple[str, str]]] = {}
self._index(obj)

def _index(self, obj: Any, parent_key=None, parent=None):
Expand Down Expand Up @@ -112,7 +113,7 @@ def bless(self, obj: Any) -> "ProxyObject":
else:
return ProxyObject(obj, _db=self)

def _key(self, obj: Any) -> Tuple[Union[str, YAMLRoot], str]:
def _key(self, obj: Any) -> tuple[Union[str, YAMLRoot], str]:
"""
Returns primary key value for this object.

Expand Down Expand Up @@ -265,6 +266,6 @@ def _map(self, obj: Any, in_range: str) -> Any:
return cls(obj)
return obj

def _attributes(self) -> List[str]:
def _attributes(self) -> list[str]:
return list(vars(self._shadowed).keys())

46 changes: 46 additions & 0 deletions linkml_runtime/linkml_model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,49 @@
Definition, EnumDefinition, SlotDefinition, ClassDefinition, Prefix, LocalName, Example, AltDescription, \
PermissibleValue, PvFormulaOptions

__all__ = [
"String",
"Integer",
"Boolean",
"Float",
"Double",
"Decimal",
"Time",
"Date",
"Datetime",
"Uriorcurie",
"Uri",
"Ncname",
"Objectidentifier",
"Nodeidentifier",
"Extension",
"Extensible",
"Annotation",
"Annotatable",
"ElementName",
"SchemaDefinitionName",
"TypeDefinitionName",
"SubsetDefinitionName",
"DefinitionName",
"EnumDefinitionName",
"SlotDefinitionName",
"ClassDefinitionName",
"PrefixPrefixPrefix",
"LocalNameLocalNameSource",
"AltDescriptionSource",
"PermissibleValueText",
"Element",
"SchemaDefinition",
"TypeDefinition",
"SubsetDefinition",
"Definition",
"EnumDefinition",
"SlotDefinition",
"ClassDefinition",
"Prefix",
"LocalName",
"Example",
"AltDescription",
"PermissibleValue",
"PvFormulaOptions",
]
33 changes: 11 additions & 22 deletions linkml_runtime/linkml_model/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,19 @@
# description: Annotations mixin
# license: https://creativecommons.org/publicdomain/zero/1.0/

import dataclasses
import re
from jsonasobj2 import JsonObj, as_dict
from typing import Optional, List, Union, Dict, ClassVar, Any
from typing import Optional, Union, ClassVar, Any
from dataclasses import dataclass

from linkml_runtime.utils.slot import Slot
from linkml_runtime.utils.metamodelcore import empty_list, empty_dict, bnode
from linkml_runtime.utils.yamlutils import YAMLRoot, extended_str, extended_float, extended_int
from linkml_runtime.utils.dataclass_extensions_376 import dataclasses_init_fn_with_kwargs
from linkml_runtime.utils.formatutils import camelcase, underscore, sfx
from linkml_runtime.utils.enumerations import EnumDefinitionImpl
from rdflib import Namespace, URIRef
from linkml_runtime.utils.metamodelcore import empty_dict
from linkml_runtime.utils.yamlutils import YAMLRoot
from rdflib import URIRef
from linkml_runtime.utils.curienamespace import CurieNamespace
from .extensions import AnyValue, Extension, ExtensionTag
from .types import Uriorcurie
from linkml_runtime.utils.metamodelcore import URIorCURIE

metamodel_version = "1.7.0"
version = "2.0.0"

# Overwrite dataclasses _init_fn to add **kwargs in __init__
dataclasses._init_fn = dataclasses_init_fn_with_kwargs

# Namespaces
LINKML = CurieNamespace('linkml', 'https://w3id.org/linkml/')
DEFAULT_ = LINKML
Expand All @@ -47,16 +36,16 @@ class Annotatable(YAMLRoot):
"""
mixin for classes that support annotations
"""
_inherited_slots: ClassVar[List[str]] = []
_inherited_slots: ClassVar[list[str]] = []

class_class_uri: ClassVar[URIRef] = LINKML["Annotatable"]
class_class_curie: ClassVar[str] = "linkml:Annotatable"
class_name: ClassVar[str] = "annotatable"
class_model_uri: ClassVar[URIRef] = LINKML.Annotatable

annotations: Optional[Union[Dict[Union[str, AnnotationTag], Union[dict, "Annotation"]], List[Union[dict, "Annotation"]]]] = empty_dict()
annotations: Optional[Union[dict[Union[str, AnnotationTag], Union[dict, "Annotation"]], list[Union[dict, "Annotation"]]]] = empty_dict()

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

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

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

tag: Union[str, AnnotationTag] = None
value: Union[dict, AnyValue] = None
annotations: Optional[Union[Dict[Union[str, AnnotationTag], Union[dict, "Annotation"]], List[Union[dict, "Annotation"]]]] = empty_dict()
annotations: Optional[Union[dict[Union[str, AnnotationTag], Union[dict, "Annotation"]], list[Union[dict, "Annotation"]]]] = empty_dict()

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

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