Skip to content

Commit

Permalink
task regen && task check
Browse files Browse the repository at this point in the history
  • Loading branch information
p1-ra committed May 18, 2021
1 parent b17a38a commit 533cc8f
Show file tree
Hide file tree
Showing 9 changed files with 249 additions and 215 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from .a_form_data import AFormData
from .a_model import AModel
from .a_model_with_properties_reference_that_are_not_object import AModelWithPropertiesReferenceThatAreNotObject
from .a_model_with_indirect_reference_property import AModelWithIndirectReferenceProperty
from .a_model_with_indirect_self_reference_property import AModelWithIndirectSelfReferenceProperty
from .a_model_with_properties_reference_that_are_not_object import AModelWithPropertiesReferenceThatAreNotObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ def to_dict(self) -> Dict[str, Any]:
@classmethod
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
d = src_dict.copy()
an_enum_indirect_ref: Union[Unset, AnEnum] = UNSET
_an_enum_indirect_ref = d.pop("an_enum_indirect_ref", UNSET)
if not isinstance(_an_enum_indirect_ref, Unset):
an_enum_indirect_ref: Union[Unset, AnEnum]
if isinstance(_an_enum_indirect_ref, Unset):
an_enum_indirect_ref = UNSET
else:
an_enum_indirect_ref = AnEnum(_an_enum_indirect_ref)

a_model_with_indirect_reference_property = cls(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
d = src_dict.copy()
required_self_ref = d.pop("required_self_ref")

an_enum: Union[Unset, AnEnum] = UNSET
_an_enum = d.pop("an_enum", UNSET)
if not isinstance(_an_enum, Unset):
an_enum: Union[Unset, AnEnum]
if isinstance(_an_enum, Unset):
an_enum = UNSET
else:
an_enum = AnEnum(_an_enum)

optional_self_ref = d.pop("optional_self_ref", UNSET)
Expand Down

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions openapi_python_client/parser/properties/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,10 @@ def from_string(*, string: str, config: Config) -> "Class":
class Schemas:
"""Structure for containing all defined, shareable, and reusable schemas (attr classes and Enums)"""

classes_by_reference: Dict[
_ReferencePath, _Holder[Union[Property, RecursiveReferenceInterupt]]
] = attr.ib(factory=dict)
classes_by_name: Dict[
_ClassName, _Holder[Union[Property, RecursiveReferenceInterupt]]
] = attr.ib(factory=dict)
classes_by_reference: Dict[_ReferencePath, _Holder[Union[Property, RecursiveReferenceInterupt]]] = attr.ib(
factory=dict
)
classes_by_name: Dict[_ClassName, _Holder[Union[Property, RecursiveReferenceInterupt]]] = attr.ib(factory=dict)
errors: List[ParseError] = attr.ib(factory=list)


Expand Down
4 changes: 2 additions & 2 deletions openapi_python_client/resolver/collision_resolver.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import hashlib
import re

from typing import Any, Dict, List, Tuple

from .reference import Reference
from .resolver_types import SchemaData

Expand Down Expand Up @@ -74,7 +74,7 @@ def _get_from_ref(self, ref: Reference, attr: SchemaData) -> SchemaData:

if list(cursor) == ["$ref"]:
ref2 = cursor["$ref"]
ref2 = re.sub(r'(.*)_\d',r'\1',ref2)
ref2 = re.sub(r"(.*)_\d", r"\1", ref2)
ref2 = Reference(ref2, self._parent)
if ref2.is_remote():
attr = self._refs[ref2.abs_path]
Expand Down
2 changes: 1 addition & 1 deletion openapi_python_client/resolver/pointer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


class Pointer:
""" https://tools.ietf.org/html/rfc6901 """
"""https://tools.ietf.org/html/rfc6901"""

def __init__(self, pointer: str) -> None:
if pointer is None or pointer != "" and not pointer.startswith("/"):
Expand Down
14 changes: 7 additions & 7 deletions openapi_python_client/resolver/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class Reference:
""" https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03 """
"""https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03"""

def __init__(self, reference: str, parent: str = None):
self._ref = reference
Expand Down Expand Up @@ -40,29 +40,29 @@ def pointer(self) -> Pointer:
return Pointer(frag)

def is_relative(self) -> bool:
""" return True if reference path is a relative path """
"""return True if reference path is a relative path"""
return not self.is_absolute()

def is_absolute(self) -> bool:
""" return True is reference path is an absolute path """
"""return True is reference path is an absolute path"""
return self._parsed_ref.netloc != ""

@property
def value(self) -> str:
return self._ref

def is_url(self) -> bool:
""" return True if the reference path is pointing to an external url location """
"""return True if the reference path is pointing to an external url location"""
return self.is_remote() and self._parsed_ref.netloc != ""

def is_remote(self) -> bool:
""" return True if the reference pointer is pointing to a remote document """
"""return True if the reference pointer is pointing to a remote document"""
return not self.is_local()

def is_local(self) -> bool:
""" return True if the reference pointer is pointing to the current document """
"""return True if the reference pointer is pointing to the current document"""
return self._parsed_ref.path == ""

def is_full_document(self) -> bool:
""" return True if the reference pointer is pointing to the whole document content """
"""return True if the reference pointer is pointing to the whole document content"""
return self.pointer.parent is None
2 changes: 1 addition & 1 deletion openapi_python_client/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def to_valid_python_identifier(value: str) -> str:
See:
https://docs.python.org/3/reference/lexical_analysis.html#identifiers
"""
new_value = fix_reserved_words(fix_keywords(sanitize(value))).lstrip('_')
new_value = fix_reserved_words(fix_keywords(sanitize(value))).lstrip("_")

if new_value.isidentifier():
return new_value
Expand Down

0 comments on commit 533cc8f

Please sign in to comment.