Skip to content

Commit fb82545

Browse files
committed
Refactor type hints for schema generator methods
- Update return type hints from `Self` to specific generator classes. - Improve clarity and type safety in method signatures. - Ensure consistency across schema generation methods.
1 parent d84f64d commit fb82545

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

src/utils/generate_config_schema.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,17 @@
1818
## --------------------------------------------------------------------------- #
1919

2020

21+
# ## Future Python Library Imports ----
22+
from __future__ import annotations
23+
2124
# ## Python StdLib Imports ----
2225
import json
2326
import os
2427
import sys
2528
from dataclasses import MISSING, fields
2629
from functools import cached_property
2730
from pathlib import Path
28-
from typing import Any, Literal, Self, Union, get_args, get_origin
31+
from typing import Any, Literal, Union, get_args, get_origin
2932

3033
# ## Python Third Party Imports ----
3134
import black
@@ -95,7 +98,7 @@ def write_schema_to_file(self, output_name: str, output_path: Path = SCHEMA_OUTP
9598

9699
class DFCSchemaGenerator(SchemaGeneratorMixin):
97100

98-
def generate_schema_headers(self) -> Self:
101+
def generate_schema_headers(self) -> DFCSchemaGenerator:
99102
self.schema: dict[str, Any] = {
100103
"$schema": "http://json-schema.org/draft-07/schema#",
101104
"$id": "https://json.schemastore.org/partial-dfc.json",
@@ -107,7 +110,7 @@ def generate_schema_headers(self) -> Self:
107110
# Return self for chaining
108111
return self
109112

110-
def generate_schema_global_properties(self) -> Self:
113+
def generate_schema_global_properties(self) -> DFCSchemaGenerator:
111114

112115
# Extract GlobalConfig fields
113116
global_fields = fields(GlobalConfig)
@@ -144,7 +147,7 @@ def generate_schema_global_properties(self) -> Self:
144147
# Return self for chaining
145148
return self
146149

147-
def generate_schema_section_properties(self) -> Self:
150+
def generate_schema_section_properties(self) -> DFCSchemaGenerator:
148151

149152
# Extract SectionConfig fields
150153
section_fields = fields(SectionConfig)
@@ -248,7 +251,7 @@ def generate_schema(self) -> Self:
248251

249252
class PyprojectSchemaGenerator(SchemaGeneratorMixin):
250253

251-
def generate_schema(self) -> Self:
254+
def generate_schema(self) -> PyprojectSchemaGenerator:
252255
self.schema = {
253256
"properties": {
254257
"tool": {

0 commit comments

Comments
 (0)