-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
7,071 additions
and
536 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,4 @@ dist | |
__pycache__ | ||
.ipynb_checkpoints | ||
|
||
src/revisit_notebook_widget/static | ||
src/revisit/static |
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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,87 @@ | ||
warnings.filterwarnings("ignore", module="pydantic") | ||
{% for decorator in decorators -%} | ||
{{ decorator }} | ||
{% endfor -%} | ||
class {{ class_name }}({{ base_class }}):{% if comment is defined %} # {{ comment }}{% endif %} | ||
{%- if description %} | ||
""" | ||
{{ description | indent(4) }} | ||
""" | ||
{%- endif %} | ||
{%- if not fields and not description %} | ||
pass | ||
{%- endif %} | ||
{%- if config %} | ||
{%- filter indent(4) %} | ||
{% include 'ConfigDict.jinja2' %} | ||
{%- endfilter %} | ||
{%- endif %} | ||
{%- for field in fields -%} | ||
{%- if not field.annotated and field.field %} | ||
{%- if not field.required %} | ||
{{ field.name }}: {{ field.type_hint }} = {{ field.field }} | ||
{%- else %} | ||
{{ field.name }}: {{ field.type_hint }} = {{ field.field }} | ||
{%- endif %} | ||
{%- else %} | ||
{%- if field.annotated %} | ||
{{ field.name }}: {{ field.annotated }} | ||
{%- else %} | ||
{{ field.name }}: {{ field.type_hint }} | ||
{%- endif %} | ||
{%- if not (field.required or (field.represented_default == 'None' and field.strip_default_none)) or field.data_type.is_optional | ||
%} = {{ field.represented_default }} | ||
{%- endif -%} | ||
{%- endif %} | ||
{%- if field.docstring %} | ||
""" | ||
{{ field.docstring | indent(4) }} | ||
""" | ||
{%- endif %} | ||
{%- for method in methods -%} | ||
{{ method }} | ||
{%- endfor -%} | ||
{%- endfor -%} | ||
|
||
# End of class | ||
|
||
class {{ class_name }}Type(TypedDict):{% if comment is defined %} # {{ comment }}{% endif %} | ||
{%- if description %} | ||
""" | ||
{{ description | indent(4) }} | ||
""" | ||
{%- endif %} | ||
{%- if not fields and not description %} | ||
pass | ||
{%- endif %} | ||
{%- if config %} | ||
{%- filter indent(4) %} | ||
{% include 'ConfigDict.jinja2' %} | ||
{%- endfilter %} | ||
{%- endif %} | ||
{%- for field in fields -%} | ||
{%- if not field.annotated and field.field %} | ||
{%- if not field.required %} | ||
{{ field.name }}: {{ field.type_hint }} = {{ field.field }} | ||
{%- else %} | ||
{{ field.name }}: {{ field.type_hint }} = {{ field.field }} | ||
{%- endif %} | ||
{%- else %} | ||
{%- if field.annotated %} | ||
{{ field.name }}: {{ field.annotated }} | ||
{%- else %} | ||
{{ field.name }}: {{ field.type_hint }} | ||
{%- endif %} | ||
{%- if not (field.required or (field.represented_default == 'None' and field.strip_default_none)) or field.data_type.is_optional | ||
%} = {{ field.represented_default }} | ||
{%- endif -%} | ||
{%- endif %} | ||
{%- if field.docstring %} | ||
""" | ||
{{ field.docstring | indent(4) }} | ||
""" | ||
{%- endif %} | ||
{%- for method in methods -%} | ||
{{ method }} | ||
{%- endfor -%} | ||
{%- endfor -%} |
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,5 @@ | ||
model_config = ConfigDict( | ||
{%- for field_name, value in config.dict(exclude_unset=True).items() %} | ||
{{ field_name }}={{ value }}, | ||
{%- endfor %} | ||
populate_by_name=True) |
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,81 @@ | ||
{%- macro get_type_hint(_fields) -%} | ||
{%- if _fields -%} | ||
{#There will only ever be a single field for RootModel#} | ||
{{- _fields[0].type_hint}} | ||
{%- endif -%} | ||
{%- endmacro -%} | ||
|
||
|
||
{% for decorator in decorators -%} | ||
{{ decorator }} | ||
{% endfor -%} | ||
|
||
class {{ class_name }}({{ base_class }}{%- if fields -%}[{{get_type_hint(fields)}}]{%- endif -%}):{% if comment is defined %} # {{ comment }}{% endif %} | ||
{%- if description %} | ||
""" | ||
{{ description | indent(4) }} | ||
""" | ||
{%- endif %} | ||
{%- if config %} | ||
{%- filter indent(4) %} | ||
{% include 'ConfigDict.jinja2' %} | ||
{%- endfilter %} | ||
{%- endif %} | ||
{%- if not fields and not description %} | ||
pass | ||
{%- else %} | ||
{%- set field = fields[0] %} | ||
{%- if not field.annotated and field.field %} | ||
root: {{ field.type_hint }} = {{ field.field }} | ||
{%- else %} | ||
{%- if field.annotated %} | ||
root: {{ field.annotated }} | ||
{%- else %} | ||
root: {{ field.type_hint }} | ||
{%- endif %} | ||
{%- if not (field.required or (field.represented_default == 'None' and field.strip_default_none)) | ||
%} = {{ field.represented_default }} | ||
{%- endif -%} | ||
{%- endif %} | ||
{%- if field.docstring %} | ||
""" | ||
{{ field.docstring | indent(4) }} | ||
""" | ||
{%- endif %} | ||
{%- endif %} | ||
|
||
# End of class | ||
|
||
class {{ class_name }}Type(TypedDict):{% if comment is defined %} # {{ comment }}{% endif %} | ||
{%- if description %} | ||
""" | ||
{{ description | indent(4) }} | ||
""" | ||
{%- endif %} | ||
{%- if config %} | ||
{%- filter indent(4) %} | ||
{% include 'ConfigDict.jinja2' %} | ||
{%- endfilter %} | ||
{%- endif %} | ||
{%- if not fields and not description %} | ||
pass | ||
{%- else %} | ||
{%- set field = fields[0] %} | ||
{%- if not field.annotated and field.field %} | ||
root: {{ field.type_hint }} = {{ field.field }} | ||
{%- else %} | ||
{%- if field.annotated %} | ||
root: {{ field.annotated }} | ||
{%- else %} | ||
root: {{ field.type_hint }} | ||
{%- endif %} | ||
{%- if not (field.required or (field.represented_default == 'None' and field.strip_default_none)) | ||
%} = {{ field.represented_default }} | ||
{%- endif -%} | ||
{%- endif %} | ||
{%- if field.docstring %} | ||
""" | ||
{{ field.docstring | indent(4) }} | ||
""" | ||
{%- endif %} | ||
{%- endif %} |
Oops, something went wrong.