Skip to content

Commit b1b3395

Browse files
authored
Merge pull request #5 from prius/dev
Stricter types (preparation to switch to openapi generator)
2 parents 3706921 + a8bf3e5 commit b1b3395

11 files changed

+147
-13
lines changed

README.generated.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ Class | Method | HTTP request | Description
223223

224224
## Documentation For Models
225225

226+
- [AnyOfGraphqlQuestionDetailSolution](docs/AnyOfGraphqlQuestionDetailSolution.md)
226227
- [BaseSubmissionResult](docs/BaseSubmissionResult.md)
227228
- [Difficulty](docs/Difficulty.md)
228229
- [GraphqlData](docs/GraphqlData.md)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# AnyOfGraphqlQuestionDetailSolution
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
7+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
8+

docs/GraphqlQuestionDetail.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Name | Type | Description | Notes
2424
**code_snippets** | [**list[GraphqlQuestionCodeSnippet]**](GraphqlQuestionCodeSnippet.md) | | [optional]
2525
**stats** | **str** | | [optional]
2626
**hints** | **list[str]** | | [optional]
27-
**solution** | [**GraphqlQuestionSolution**](GraphqlQuestionSolution.md) | | [optional]
27+
**solution** | [**AnyOfGraphqlQuestionDetailSolution**](AnyOfGraphqlQuestionDetailSolution.md) | | [optional]
2828
**status** | **str** | | [optional]
2929
**sample_test_case** | **str** | | [optional]
3030
**judger_available** | **bool** | | [optional]

docs/Stat.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
Name | Type | Description | Notes
55
------------ | ------------- | ------------- | -------------
66
**question_id** | **int** | |
7-
**question__article__live** | **str** | | [optional]
7+
**question__article__live** | **bool** | | [optional]
88
**question__article__slug** | **str** | | [optional]
9-
**question__article__has_video_solution** | **str** | | [optional]
9+
**question__article__has_video_solution** | **bool** | | [optional]
1010
**question__title** | **str** | |
1111
**question__title_slug** | **str** | |
1212
**question__hide** | **bool** | |

leetcode/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from leetcode.api_client import ApiClient
2121
from leetcode.configuration import Configuration
2222
# import models into sdk package
23+
from leetcode.models.any_of_graphql_question_detail_solution import AnyOfGraphqlQuestionDetailSolution
2324
from leetcode.models.base_submission_result import BaseSubmissionResult
2425
from leetcode.models.difficulty import Difficulty
2526
from leetcode.models.graphql_data import GraphqlData

leetcode/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from __future__ import absolute_import
1515

1616
# import models into model package
17+
from leetcode.models.any_of_graphql_question_detail_solution import AnyOfGraphqlQuestionDetailSolution
1718
from leetcode.models.base_submission_result import BaseSubmissionResult
1819
from leetcode.models.difficulty import Difficulty
1920
from leetcode.models.graphql_data import GraphqlData
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# coding: utf-8
2+
3+
"""
4+
Leetcode API
5+
6+
Leetcode API implementation. # noqa: E501
7+
8+
OpenAPI spec version: 1.0.1-1
9+
Contact: pv.safronov@gmail.com
10+
Generated by: https://github.com/swagger-api/swagger-codegen.git
11+
"""
12+
13+
import pprint
14+
import re # noqa: F401
15+
16+
import six
17+
18+
class AnyOfGraphqlQuestionDetailSolution(object):
19+
"""NOTE: This class is auto generated by the swagger code generator program.
20+
21+
Do not edit the class manually.
22+
"""
23+
"""
24+
Attributes:
25+
swagger_types (dict): The key is attribute name
26+
and the value is attribute type.
27+
attribute_map (dict): The key is attribute name
28+
and the value is json key in definition.
29+
"""
30+
swagger_types = {
31+
}
32+
33+
attribute_map = {
34+
}
35+
36+
def __init__(self): # noqa: E501
37+
"""AnyOfGraphqlQuestionDetailSolution - a model defined in Swagger""" # noqa: E501
38+
self.discriminator = None
39+
40+
def to_dict(self):
41+
"""Returns the model properties as a dict"""
42+
result = {}
43+
44+
for attr, _ in six.iteritems(self.swagger_types):
45+
value = getattr(self, attr)
46+
if isinstance(value, list):
47+
result[attr] = list(map(
48+
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
49+
value
50+
))
51+
elif hasattr(value, "to_dict"):
52+
result[attr] = value.to_dict()
53+
elif isinstance(value, dict):
54+
result[attr] = dict(map(
55+
lambda item: (item[0], item[1].to_dict())
56+
if hasattr(item[1], "to_dict") else item,
57+
value.items()
58+
))
59+
else:
60+
result[attr] = value
61+
if issubclass(AnyOfGraphqlQuestionDetailSolution, dict):
62+
for key, value in self.items():
63+
result[key] = value
64+
65+
return result
66+
67+
def to_str(self):
68+
"""Returns the string representation of the model"""
69+
return pprint.pformat(self.to_dict())
70+
71+
def __repr__(self):
72+
"""For `print` and `pprint`"""
73+
return self.to_str()
74+
75+
def __eq__(self, other):
76+
"""Returns true if both objects are equal"""
77+
if not isinstance(other, AnyOfGraphqlQuestionDetailSolution):
78+
return False
79+
80+
return self.__dict__ == other.__dict__
81+
82+
def __ne__(self, other):
83+
"""Returns true if both objects are not equal"""
84+
return not self == other

leetcode/models/graphql_question_detail.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class GraphqlQuestionDetail(object):
4949
'code_snippets': 'list[GraphqlQuestionCodeSnippet]',
5050
'stats': 'str',
5151
'hints': 'list[str]',
52-
'solution': 'GraphqlQuestionSolution',
52+
'solution': 'AnyOfGraphqlQuestionDetailSolution',
5353
'status': 'str',
5454
'sample_test_case': 'str',
5555
'judger_available': 'bool',
@@ -644,7 +644,7 @@ def solution(self):
644644
645645
646646
:return: The solution of this GraphqlQuestionDetail. # noqa: E501
647-
:rtype: GraphqlQuestionSolution
647+
:rtype: AnyOfGraphqlQuestionDetailSolution
648648
"""
649649
return self._solution
650650

@@ -654,7 +654,7 @@ def solution(self, solution):
654654
655655
656656
:param solution: The solution of this GraphqlQuestionDetail. # noqa: E501
657-
:type: GraphqlQuestionSolution
657+
:type: AnyOfGraphqlQuestionDetailSolution
658658
"""
659659

660660
self._solution = solution

leetcode/models/stat.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ class Stat(object):
2929
"""
3030
swagger_types = {
3131
'question_id': 'int',
32-
'question__article__live': 'str',
32+
'question__article__live': 'bool',
3333
'question__article__slug': 'str',
34-
'question__article__has_video_solution': 'str',
34+
'question__article__has_video_solution': 'bool',
3535
'question__title': 'str',
3636
'question__title_slug': 'str',
3737
'question__hide': 'bool',
@@ -113,7 +113,7 @@ def question__article__live(self):
113113
114114
115115
:return: The question__article__live of this Stat. # noqa: E501
116-
:rtype: str
116+
:rtype: bool
117117
"""
118118
return self._question__article__live
119119

@@ -123,7 +123,7 @@ def question__article__live(self, question__article__live):
123123
124124
125125
:param question__article__live: The question__article__live of this Stat. # noqa: E501
126-
:type: str
126+
:type: bool
127127
"""
128128

129129
self._question__article__live = question__article__live
@@ -155,7 +155,7 @@ def question__article__has_video_solution(self):
155155
156156
157157
:return: The question__article__has_video_solution of this Stat. # noqa: E501
158-
:rtype: str
158+
:rtype: bool
159159
"""
160160
return self._question__article__has_video_solution
161161

@@ -165,7 +165,7 @@ def question__article__has_video_solution(self, question__article__has_video_sol
165165
166166
167167
:param question__article__has_video_solution: The question__article__has_video_solution of this Stat. # noqa: E501
168-
:type: str
168+
:type: bool
169169
"""
170170

171171
self._question__article__has_video_solution = question__article__has_video_solution

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from setuptools import find_packages, setup # noqa: H301
1313

1414
NAME = "python-leetcode"
15-
VERSION = "1.0.6"
15+
VERSION = "1.0.7"
1616

1717
with open("README.md") as readme:
1818
DESCRIPTION = readme.read()
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# coding: utf-8
2+
3+
"""
4+
Leetcode API
5+
6+
Leetcode API implementation. # noqa: E501
7+
8+
OpenAPI spec version: 1.0.1-1
9+
Contact: pv.safronov@gmail.com
10+
Generated by: https://github.com/swagger-api/swagger-codegen.git
11+
"""
12+
13+
from __future__ import absolute_import
14+
15+
import unittest
16+
17+
import leetcode
18+
from leetcode.models.any_of_graphql_question_detail_solution import AnyOfGraphqlQuestionDetailSolution # noqa: E501
19+
from leetcode.rest import ApiException
20+
21+
22+
class TestAnyOfGraphqlQuestionDetailSolution(unittest.TestCase):
23+
"""AnyOfGraphqlQuestionDetailSolution unit test stubs"""
24+
25+
def setUp(self):
26+
pass
27+
28+
def tearDown(self):
29+
pass
30+
31+
def testAnyOfGraphqlQuestionDetailSolution(self):
32+
"""Test AnyOfGraphqlQuestionDetailSolution"""
33+
# FIXME: construct object with mandatory attributes with example values
34+
# model = leetcode.models.any_of_graphql_question_detail_solution.AnyOfGraphqlQuestionDetailSolution() # noqa: E501
35+
pass
36+
37+
38+
if __name__ == '__main__':
39+
unittest.main()

0 commit comments

Comments
 (0)