mirror of
https://github.com/p2p-ld/nwb-linkml.git
synced 2025-01-10 06:04:28 +00:00
lint
This commit is contained in:
parent
fe7e9f89ca
commit
cc334ae195
2 changed files with 10 additions and 6 deletions
|
@ -15,8 +15,8 @@ from typing import ClassVar, Dict, List, Optional, Tuple
|
||||||
from linkml.generators import PydanticGenerator
|
from linkml.generators import PydanticGenerator
|
||||||
from linkml.generators.pydanticgen.array import ArrayRepresentation, NumpydanticArray
|
from linkml.generators.pydanticgen.array import ArrayRepresentation, NumpydanticArray
|
||||||
from linkml.generators.pydanticgen.build import ClassResult, SlotResult
|
from linkml.generators.pydanticgen.build import ClassResult, SlotResult
|
||||||
from linkml.generators.pydanticgen.template import Import, Imports, PydanticModule
|
|
||||||
from linkml.generators.pydanticgen.pydanticgen import SplitMode
|
from linkml.generators.pydanticgen.pydanticgen import SplitMode
|
||||||
|
from linkml.generators.pydanticgen.template import Import, Imports, PydanticModule
|
||||||
from linkml_runtime.linkml_model.meta import (
|
from linkml_runtime.linkml_model.meta import (
|
||||||
ArrayExpression,
|
ArrayExpression,
|
||||||
SchemaDefinition,
|
SchemaDefinition,
|
||||||
|
@ -96,6 +96,10 @@ class NWBPydanticGenerator(PydanticGenerator):
|
||||||
raise ValueError("Slot cannot have both range and any_of defined")
|
raise ValueError("Slot cannot have both range and any_of defined")
|
||||||
|
|
||||||
def render(self) -> PydanticModule:
|
def render(self) -> PydanticModule:
|
||||||
|
"""
|
||||||
|
Override of super's render method to switch the split_mode before generation depending
|
||||||
|
on whether it's a namespace schema or not
|
||||||
|
"""
|
||||||
is_namespace = False
|
is_namespace = False
|
||||||
ns_annotation = self.schemaview.schema.annotations.get("is_namespace", None)
|
ns_annotation = self.schemaview.schema.annotations.get("is_namespace", None)
|
||||||
if ns_annotation:
|
if ns_annotation:
|
||||||
|
|
|
@ -3,14 +3,14 @@ Provider for pydantic models.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import importlib
|
import importlib
|
||||||
|
import multiprocessing as mp
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
from importlib.abc import MetaPathFinder
|
from importlib.abc import MetaPathFinder
|
||||||
from importlib.machinery import ModuleSpec
|
from importlib.machinery import ModuleSpec
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from types import ModuleType
|
from types import ModuleType
|
||||||
from typing import List, Optional, Type, TYPE_CHECKING
|
from typing import TYPE_CHECKING, List, Optional, Type
|
||||||
import multiprocessing as mp
|
|
||||||
|
|
||||||
from linkml.generators.pydanticgen.pydanticgen import SplitMode, _ensure_inits, _import_to_path
|
from linkml.generators.pydanticgen.pydanticgen import SplitMode, _ensure_inits, _import_to_path
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
@ -179,7 +179,7 @@ class PydanticProvider(Provider):
|
||||||
res.append(serialized)
|
res.append(serialized)
|
||||||
|
|
||||||
# then each of the other schemas :)
|
# then each of the other schemas :)
|
||||||
imported_schema: dict[str, "SchemaDefinition"] = {
|
imported_schema: dict[str, SchemaDefinition] = {
|
||||||
gen.generate_module_import(sch): sch for sch in gen.schemaview.schema_map.values()
|
gen.generate_module_import(sch): sch for sch in gen.schemaview.schema_map.values()
|
||||||
}
|
}
|
||||||
generated_imports = [i for i in rendered.python_imports if i.schema]
|
generated_imports = [i for i in rendered.python_imports if i.schema]
|
||||||
|
@ -208,10 +208,10 @@ class PydanticProvider(Provider):
|
||||||
with mp.Pool(min(mp.cpu_count(), len(tasks))) as pool:
|
with mp.Pool(min(mp.cpu_count(), len(tasks))) as pool:
|
||||||
mp_results = [pool.apply_async(self._generate_single, t) for t in tasks]
|
mp_results = [pool.apply_async(self._generate_single, t) for t in tasks]
|
||||||
for result in mp_results:
|
for result in mp_results:
|
||||||
res.append(result.get())
|
res.append(result.get()) # noqa: PERF401 - false positive
|
||||||
else:
|
else:
|
||||||
for task in tasks:
|
for task in tasks:
|
||||||
res.append(self._generate_single(*task))
|
res.append(self._generate_single(*task)) # noqa: PERF401 - false positive
|
||||||
|
|
||||||
# make __init__.py files if we generated any files
|
# make __init__.py files if we generated any files
|
||||||
if len(module_paths) > 0:
|
if len(module_paths) > 0:
|
||||||
|
|
Loading…
Reference in a new issue