-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rename ConverterRetort to ConversionRetort
add high-level methods to AdornedRetort add convert high-level function and method
- Loading branch information
Showing
6 changed files
with
210 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from dataclasses import dataclass | ||
|
||
from adaptix.conversion import convert | ||
|
||
|
||
@dataclass | ||
class Person: | ||
name: str | ||
|
||
|
||
@dataclass | ||
class Book: | ||
title: str | ||
price: int | ||
author: Person | ||
|
||
|
||
@dataclass | ||
class PersonDTO: | ||
name: str | ||
|
||
|
||
@dataclass | ||
class BookDTO: | ||
title: str | ||
price: int | ||
author: PersonDTO | ||
|
||
|
||
assert ( | ||
convert( | ||
Book(title="Fahrenheit 451", price=100, author=Person("Ray Bradbury")), | ||
BookDTO, | ||
) | ||
== | ||
BookDTO(title="Fahrenheit 451", price=100, author=PersonDTO("Ray Bradbury")) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
from adaptix._internal.conversion.facade.func import get_converter, impl_converter | ||
from adaptix._internal.conversion.facade.func import convert, get_converter, impl_converter | ||
from adaptix._internal.conversion.facade.provider import ( | ||
allow_unlinked_optional, | ||
coercer, | ||
forbid_unlinked_optional, | ||
link, | ||
) | ||
from adaptix._internal.conversion.facade.retort import AdornedConverterRetort, ConverterRetort, FilledConverterRetort | ||
from adaptix._internal.conversion.facade.retort import AdornedConversionRetort, ConversionRetort, FilledConversionRetort | ||
|
||
__all__ = ( | ||
'convert', | ||
'get_converter', | ||
'impl_converter', | ||
'link', | ||
'coercer', | ||
'allow_unlinked_optional', | ||
'forbid_unlinked_optional', | ||
'AdornedConverterRetort', | ||
'FilledConverterRetort', | ||
'ConverterRetort', | ||
'AdornedConversionRetort', | ||
'FilledConversionRetort', | ||
'ConversionRetort', | ||
) |
Oops, something went wrong.