Skip to content

Commit

Permalink
deploy: 8602df6
Browse files Browse the repository at this point in the history
  • Loading branch information
danielSanchezQ committed Sep 10, 2024
1 parent 5be3fce commit 9d112bd
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 797 deletions.
143 changes: 2 additions & 141 deletions prelude.html
Original file line number Diff line number Diff line change
Expand Up @@ -752,71 +752,7 @@ <h3>Inherited members</h3>
:return: Self if self is Some(T) otherwise
:raises: EarlyReturnException(Empty)
&#34;&#34;&#34;
return self.early_return()

@classmethod
def __get_validators__(cls):
yield cls.__validate

@classmethod
def __validate(cls, value: Union[&#34;Some&#34;, &#34;Empty&#34;, Dict], field: &#34;ModelField&#34;):
if isinstance(value, Some):
return cls.__validate_some(value, field)
elif isinstance(value, Empty):
return cls.__validate_empty(value, field)
elif isinstance(value, dict):
return cls.__validate_dict(value, field)

raise TypeError(&#34;Unable to validate Option&#34;) # pragma: no cover

@classmethod
def __validate_some(cls, value: &#34;Some&#34;, field: &#34;ModelField&#34;):
import pydantic

if not field.sub_fields:
raise TypeError(&#34;No subfields found for Some&#34;)

field_value = field.sub_fields[0]
valid_value, error = field_value.validate(value.Some, {}, loc=&#34;&#34;)
if error:
# ignore type since it do not come from a base model
raise pydantic.ValidationError((error, ), Some) # type: ignore

return Some(valid_value)

@classmethod
def __validate_empty(cls, _: &#34;Empty&#34;, field: &#34;ModelField&#34;):
if field.sub_fields:
raise TypeError(&#34;Empty value cannot be bound to external types&#34;)

return Empty()

@classmethod
def __validate_dict(cls, value: Dict, field: &#34;ModelField&#34;):
import pydantic

if value == {}:
return Empty()

if len(value) != 1:
raise TypeError(
&#34;Extra object parameters found, Option can have strictly 0 (Empty) or 1 Value (Some)&#34;,
)

inner_value = value.get(&#34;Some&#34;)
if inner_value is None:
raise TypeError(&#34;Non Empty Option do not have a proper Value&#34;)

if not field.sub_fields:
raise TypeError(&#34;Cannot check Option pydantic subfields validations&#34;) # pragma: no cover

field_value = field.sub_fields[0]
valid_value, error = field_value.validate(value[&#34;Some&#34;], {}, loc=&#34;&#34;)
if error:
# ignore type since it do not come from a base model
raise pydantic.ValidationError(error, Option) # type: ignore # pragma: no cover

return Some(valid_value)</code></pre>
return self.early_return()</code></pre>
</details>
<h3>Ancestors</h3>
<ul class="hlist">
Expand Down Expand Up @@ -1316,82 +1252,7 @@ <h3>Methods</h3>
return self.contains(item)

def __iter__(self) -&gt; Iterator[T]:
return self.iter()

@classmethod
def __get_validators__(cls):
yield cls.__validate

@classmethod
def __validate(cls, value: Union[&#34;Ok&#34;, &#34;Err&#34;, Dict], field: &#34;ModelField&#34;):
if isinstance(value, Ok):
return cls.__validate_ok(value, field)
elif isinstance(value, Err):
return cls.__validate_err(value, field)
elif isinstance(value, dict):
return cls.__validate_dict(value, field)

raise TypeError(&#34;Unable to validate Result&#34;) # pragma: no cover

@classmethod
def __validate_ok(cls, value: &#34;Ok&#34;, field: &#34;ModelField&#34;):
import pydantic

if not field.sub_fields or len(field.sub_fields) != 2:
raise TypeError(&#34;Wrong subfields found for Ok&#34;) # pragma: no cover

field_value = field.sub_fields[0]
valid_value, error = field_value.validate(value.Ok, {}, loc=&#34;&#34;)
if error:
# ignore type since it do not come from a base model
raise pydantic.ValidationError(error, Result) # type: ignore

return Ok(valid_value)

@classmethod
def __validate_err(cls, value: &#34;Err&#34;, field: &#34;ModelField&#34;):
import pydantic

if not field.sub_fields or len(field.sub_fields) != 2:
raise TypeError(&#34;Wrong subfields found for Ok&#34;) # pragma: no cover

field_value = field.sub_fields[1]
valid_value, error = field_value.validate(value.Error, {}, loc=&#34;&#34;)
if error:
# ignore type since it do not come from a base model
raise pydantic.ValidationError(error, Result) # type: ignore

return Err(valid_value)

@classmethod
def __validate_dict(cls, value: Dict, field: &#34;ModelField&#34;): # mypy: ignore
import pydantic

if not field.sub_fields or len(field.sub_fields) != 2:
raise TypeError(&#34;Wrong subfields found for Ok&#34;) # pragma: no cover

if len(value) != 1:
raise TypeError(
&#34;Extra object parameters found, Results have strictly 1 value (either Value (Ok) or Error (Err))&#34;
) # pragma: no cover

return_class: Callable[[Any], Any]
inner_value: Any
if &#34;Ok&#34; in value:
inner_value, return_class, subfield = value.get(&#34;Ok&#34;), Ok, 0
elif &#34;Error&#34; in value:
inner_value, return_class, subfield = value.get(&#34;Error&#34;), Err, 1
else:
# should never be able to reach here
raise TypeError(&#34;Cannot find any Result correct value&#34;) # pragma: no cover

field_value = field.sub_fields[subfield]
valid_value, error = field_value.validate(inner_value, {}, loc=&#34;&#34;)
if error:
# ignore type since it do not come from a base model
raise pydantic.ValidationError(error, Result) # type: ignore # pragma: no cover

return return_class(valid_value)</code></pre>
return self.iter()</code></pre>
</details>
<h3>Ancestors</h3>
<ul class="hlist">
Expand Down
5 changes: 0 additions & 5 deletions tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ <h2 class="section-title" id="header-submodules">Sub-modules</h2>
<dd>
<div class="desc"></div>
</dd>
<dt><code class="name"><a title="rusty_results.tests.serde" href="serde/index.html">rusty_results.tests.serde</a></code></dt>
<dd>
<div class="desc"></div>
</dd>
</dl>
</section>
<section>
Expand All @@ -69,7 +65,6 @@ <h2 class="section-title" id="header-submodules">Sub-modules</h2>
<li><code><a title="rusty_results.tests.exceptions" href="exceptions/index.html">rusty_results.tests.exceptions</a></code></li>
<li><code><a title="rusty_results.tests.option" href="option/index.html">rusty_results.tests.option</a></code></li>
<li><code><a title="rusty_results.tests.result" href="result/index.html">rusty_results.tests.result</a></code></li>
<li><code><a title="rusty_results.tests.serde" href="serde/index.html">rusty_results.tests.serde</a></code></li>
</ul>
</li>
</ul>
Expand Down
82 changes: 0 additions & 82 deletions tests/serde/index.html

This file was deleted.

Loading

0 comments on commit 9d112bd

Please sign in to comment.