Skip to content

Commit 1669039

Browse files
committed
Update create Types
1 parent 3d3d5c6 commit 1669039

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

cppython/builder.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -375,10 +375,10 @@ def solve(
375375
return combos[0]
376376

377377
@staticmethod
378-
def create_scm(
378+
def create_scm[T: SCM](
379379
core_data: CoreData,
380-
scm_type: type[SCM],
381-
) -> SCM:
380+
scm_type: type[T],
381+
) -> T:
382382
"""Creates a source control manager from input configuration
383383
384384
Args:
@@ -391,17 +391,17 @@ def create_scm(
391391
cppython_plugin_data = resolve_cppython_plugin(core_data.cppython_data, scm_type)
392392
scm_data = resolve_scm(core_data.project_data, cppython_plugin_data)
393393

394-
plugin = cast(SCM, scm_type(scm_data))
394+
plugin = scm_type(scm_data)
395395

396396
return plugin
397397

398-
def create_generator(
398+
def create_generator[T: Generator](
399399
self,
400400
core_data: CoreData,
401401
pep621_data: PEP621Data,
402402
generator_configuration: dict[str, Any],
403-
generator_type: type[Generator],
404-
) -> Generator:
403+
generator_type: type[T],
404+
) -> T:
405405
"""Creates a generator from input configuration
406406
407407
Args:
@@ -428,15 +428,15 @@ def create_generator(
428428
cppython_data=cppython_plugin_data,
429429
)
430430

431-
return cast(Generator, generator_type(generator_data, core_plugin_data, generator_configuration))
431+
return generator_type(generator_data, core_plugin_data, generator_configuration)
432432

433-
def create_provider(
433+
def create_provider[T: Provider](
434434
self,
435435
core_data: CoreData,
436436
pep621_data: PEP621Data,
437437
provider_configuration: dict[str, Any],
438-
provider_type: type[Provider],
439-
) -> Provider:
438+
provider_type: type[T],
439+
) -> T:
440440
"""Creates Providers from input data
441441
442442
Args:
@@ -463,7 +463,7 @@ def create_provider(
463463
cppython_data=cppython_plugin_data,
464464
)
465465

466-
return cast(Provider, provider_type(provider_data, core_plugin_data, provider_configuration))
466+
return provider_type(provider_data, core_plugin_data, provider_configuration)
467467

468468

469469
class Builder:

0 commit comments

Comments
 (0)