-
Notifications
You must be signed in to change notification settings - Fork 390
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate mixins instead of type annotations
- Loading branch information
1 parent
e7361dc
commit a1ca831
Showing
59 changed files
with
1,834 additions
and
172 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
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
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
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,51 @@ | ||
# DO NOT EDIT. This file was generated with: | ||
# | ||
# $ gen-schema-mixins | ||
|
||
"""Type definitions for generated methods on schema classes""" | ||
|
||
from typing import cast, TYPE_CHECKING | ||
if TYPE_CHECKING: | ||
from edb.schema import schema as s_schema | ||
from edb.schema import orm as s_orm | ||
from edb.schema import objects | ||
from edb.schema import annos | ||
|
||
|
||
class AnnotationValueMixin: | ||
|
||
def get_subject( | ||
self, schema: 's_schema.Schema' | ||
) -> 'objects.Object': | ||
val = s_orm.get_field_value(self, schema, 'subject') | ||
return cast(objects.Object, val) | ||
|
||
def get_annotation( | ||
self, schema: 's_schema.Schema' | ||
) -> 'annos.Annotation': | ||
val = s_orm.get_field_value(self, schema, 'annotation') | ||
return cast(annos.Annotation, val) | ||
|
||
def get_value( | ||
self, schema: 's_schema.Schema' | ||
) -> 'str': | ||
val = s_orm.get_field_value(self, schema, 'value') | ||
return cast(str, val) | ||
|
||
|
||
class AnnotationSubjectMixin: | ||
|
||
def get_annotations( | ||
self, schema: 's_schema.Schema' | ||
) -> 'objects.ObjectIndexByShortname[annos.AnnotationValue]': | ||
val = s_orm.get_field_value(self, schema, 'annotations') | ||
return cast(objects.ObjectIndexByShortname[annos.AnnotationValue], val) | ||
|
||
|
||
class AnnotationMixin: | ||
|
||
def get_inheritable( | ||
self, schema: 's_schema.Schema' | ||
) -> 'bool': | ||
val = s_orm.get_field_value(self, schema, 'inheritable') | ||
return cast(bool, val) |
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,69 @@ | ||
# DO NOT EDIT. This file was generated with: | ||
# | ||
# $ gen-schema-mixins | ||
|
||
"""Type definitions for generated methods on schema classes""" | ||
|
||
from typing import cast, TYPE_CHECKING | ||
if TYPE_CHECKING: | ||
from edb.schema import schema as s_schema | ||
from edb.schema import orm as s_orm | ||
from edb.edgeql import ast | ||
from edb.schema import types | ||
|
||
|
||
class CastMixin: | ||
|
||
def get_from_type( | ||
self, schema: 's_schema.Schema' | ||
) -> 'types.Type': | ||
val = s_orm.get_field_value(self, schema, 'from_type') | ||
return cast(types.Type, val) | ||
|
||
def get_to_type( | ||
self, schema: 's_schema.Schema' | ||
) -> 'types.Type': | ||
val = s_orm.get_field_value(self, schema, 'to_type') | ||
return cast(types.Type, val) | ||
|
||
def get_allow_implicit( | ||
self, schema: 's_schema.Schema' | ||
) -> 'bool': | ||
val = s_orm.get_field_value(self, schema, 'allow_implicit') | ||
return cast(bool, val) | ||
|
||
def get_allow_assignment( | ||
self, schema: 's_schema.Schema' | ||
) -> 'bool': | ||
val = s_orm.get_field_value(self, schema, 'allow_assignment') | ||
return cast(bool, val) | ||
|
||
def get_language( | ||
self, schema: 's_schema.Schema' | ||
) -> 'ast.Language': | ||
val = s_orm.get_field_value(self, schema, 'language') | ||
return cast(ast.Language, val) | ||
|
||
def get_from_function( | ||
self, schema: 's_schema.Schema' | ||
) -> 'str': | ||
val = s_orm.get_field_value(self, schema, 'from_function') | ||
return cast(str, val) | ||
|
||
def get_from_expr( | ||
self, schema: 's_schema.Schema' | ||
) -> 'bool': | ||
val = s_orm.get_field_value(self, schema, 'from_expr') | ||
return cast(bool, val) | ||
|
||
def get_from_cast( | ||
self, schema: 's_schema.Schema' | ||
) -> 'bool': | ||
val = s_orm.get_field_value(self, schema, 'from_cast') | ||
return cast(bool, val) | ||
|
||
def get_code( | ||
self, schema: 's_schema.Schema' | ||
) -> 'str': | ||
val = s_orm.get_field_value(self, schema, 'code') | ||
return cast(str, val) |
Oops, something went wrong.