refactor: remove unnecessary TYPE_CHECKING usage
- remove TYPE_CHECKING import from processors.py and use direct import - remove unused TYPE_CHECKING block from metadata_fields.py - replace TYPE_CHECKING with direct imports in models.py - remove redundant local imports within methods Direct imports work fine since there are no circular dependencies. This makes the code cleaner and types available at runtime.
This commit is contained in:
parent
34c81750ce
commit
c0babcce02
3 changed files with 11 additions and 24 deletions
|
@ -6,14 +6,12 @@ including license processing and abstract extraction/cleaning.
|
|||
"""
|
||||
|
||||
import re
|
||||
from typing import TYPE_CHECKING, Any
|
||||
from typing import Any
|
||||
|
||||
from rich.console import Console
|
||||
|
||||
from ..core.models import Abstract, License
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .client import APIClient
|
||||
from .client import APIClient
|
||||
|
||||
|
||||
class LicenseProcessor:
|
||||
|
@ -71,7 +69,7 @@ class AbstractProcessor:
|
|||
# Icons for console output - TODO: should be moved to a constants module
|
||||
ICONS = {"info": "ℹ️", "warning": "⚠️", "error": "❌"}
|
||||
|
||||
def __init__(self, api_client: "APIClient", console: Console | None = None):
|
||||
def __init__(self, api_client: APIClient, console: Console | None = None):
|
||||
"""
|
||||
Initialize with an APIClient instance.
|
||||
|
||||
|
|
|
@ -9,10 +9,7 @@ from collections.abc import Sequence
|
|||
from dataclasses import dataclass, field
|
||||
from enum import Enum
|
||||
from functools import reduce
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
if TYPE_CHECKING:
|
||||
pass
|
||||
from typing import Any
|
||||
|
||||
|
||||
class FieldType(Enum):
|
||||
|
|
|
@ -6,13 +6,11 @@ for representing people, institutions, licenses, and abstracts.
|
|||
"""
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .metadata_fields import (
|
||||
ControlledVocabularyMetadataField,
|
||||
PrimitiveMetadataField,
|
||||
)
|
||||
from .metadata_fields import (
|
||||
ControlledVocabularyMetadataField,
|
||||
PrimitiveMetadataField,
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
|
@ -28,7 +26,7 @@ class Institution:
|
|||
display_name: str
|
||||
ror: str = ""
|
||||
|
||||
def affiliation_field(self) -> "PrimitiveMetadataField":
|
||||
def affiliation_field(self) -> PrimitiveMetadataField:
|
||||
"""
|
||||
Create a metadata field for the affiliation.
|
||||
|
||||
|
@ -36,7 +34,6 @@ class Institution:
|
|||
PrimitiveMetadataField: A metadata field representing the institution,
|
||||
using ROR ID when available.
|
||||
"""
|
||||
from .metadata_fields import PrimitiveMetadataField
|
||||
|
||||
if self.ror:
|
||||
expanded_value = {
|
||||
|
@ -111,7 +108,7 @@ class Person:
|
|||
|
||||
def author_fields(
|
||||
self,
|
||||
) -> list["PrimitiveMetadataField | ControlledVocabularyMetadataField"]:
|
||||
) -> list[PrimitiveMetadataField | ControlledVocabularyMetadataField]:
|
||||
"""
|
||||
Build metadata fields for the author.
|
||||
|
||||
|
@ -122,10 +119,6 @@ class Person:
|
|||
list: List of metadata fields representing the author, including name,
|
||||
affiliation, and optionally ORCID identifier information.
|
||||
"""
|
||||
from .metadata_fields import (
|
||||
ControlledVocabularyMetadataField,
|
||||
PrimitiveMetadataField,
|
||||
)
|
||||
|
||||
affiliation_field = None
|
||||
if isinstance(self.affiliation, Institution):
|
||||
|
@ -150,7 +143,7 @@ class Person:
|
|||
affiliation_field,
|
||||
]
|
||||
|
||||
def dataset_contact_fields(self) -> list["PrimitiveMetadataField"]:
|
||||
def dataset_contact_fields(self) -> list[PrimitiveMetadataField]:
|
||||
"""
|
||||
Generate metadata fields for dataset contact.
|
||||
|
||||
|
@ -161,7 +154,6 @@ class Person:
|
|||
list: List of metadata fields for the dataset contact including name,
|
||||
affiliation, and email address.
|
||||
"""
|
||||
from .metadata_fields import PrimitiveMetadataField
|
||||
|
||||
affiliation_field = None
|
||||
if isinstance(self.affiliation, Institution):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue