From 815c42acbeefb7bb487330f40cc44fe3bf510a7f Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Fri, 22 Oct 2021 14:49:34 +0100 Subject: [PATCH 01/24] Added real tests --- .github/workflows/pytest.yml | 6 +- test/base.py | 24 +++ ...est_graphql_request_get_question_detail.py | 173 ++++++++++++++++++ test/test_graphql_request_user.py | 35 ++++ 4 files changed, 237 insertions(+), 1 deletion(-) create mode 100644 test/base.py create mode 100644 test/test_graphql_request_get_question_detail.py create mode 100644 test/test_graphql_request_user.py diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 5d8ed9b..477d11b 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -17,5 +17,9 @@ jobs: run: pip install -r test-requirements.txt - name: Install pytest run: pip install pytest + - name: pip freeze (for debug purposes) + run: pip freeze - name: Run tests - run: pytest + run: pytest -vvvv -s + env: + LEETCODE_SESSION_ID: ${{ secrets.LEETCODE_SESSION }} diff --git a/test/base.py b/test/base.py new file mode 100644 index 0000000..adeee2b --- /dev/null +++ b/test/base.py @@ -0,0 +1,24 @@ +import os + +import leetcode +import leetcode.auth + + +class BaseTest: + def setup(self) -> None: + session_id = os.environ["LEETCODE_SESSION_ID"] + csrftoken = leetcode.auth.get_csrf_cookie(session_id) + + configuration = leetcode.Configuration() + + configuration.api_key["x-csrftoken"] = csrftoken + configuration.api_key["csrftoken"] = csrftoken + configuration.api_key["LEETCODE_SESSION"] = session_id + configuration.api_key["Referer"] = "https://leetcode.com" + + configuration.debug = False + + self._api_instance = leetcode.DefaultApi(leetcode.ApiClient(configuration)) + + def teardown(self) -> None: + pass diff --git a/test/test_graphql_request_get_question_detail.py b/test/test_graphql_request_get_question_detail.py new file mode 100644 index 0000000..34873d8 --- /dev/null +++ b/test/test_graphql_request_get_question_detail.py @@ -0,0 +1,173 @@ +import json +import test.base + +import leetcode + + +class TestGraphqlGetQuestionDetail(test.base.BaseTest): + def test_request(self) -> None: + graphql_request = leetcode.GraphqlQuery( + query=""" + query getQuestionDetail($titleSlug: String!) { + question(titleSlug: $titleSlug) { + questionId + questionFrontendId + boundTopicId + title + content + translatedTitle + isPaidOnly + difficulty + likes + dislikes + isLiked + similarQuestions + contributors { + username + profileUrl + avatarUrl + __typename + } + langToValidPlayground + topicTags { + name + slug + translatedName + __typename + } + companyTagStats + codeSnippets { + lang + langSlug + code + __typename + } + stats + codeDefinition + hints + solution { + id + canSeeDetail + __typename + } + status + sampleTestCase + enableRunCode + metaData + translatedContent + judgerAvailable + judgeType + mysqlSchemas + enableTestMode + envInfo + __typename + } + } + """, + variables=leetcode.GraphqlQueryVariables(title_slug="two-sum"), + operation_name="getQuestionDetail", + ) + + response = self._api_instance.graphql_post(body=graphql_request) + + data = response.data + + assert data + + question = data.question + user = data.user + + assert user is None + + assert question.question_id == "1" + assert question.question_frontend_id == "1" + assert question.bound_topic_id is None + assert question.title == "Two Sum" + assert len(question.content) > 10 + assert question.translated_title is None + assert question.is_paid_only is False + assert question.difficulty == "Easy" + assert question.likes > 0 + assert question.dislikes > 0 + assert question.is_liked is None + assert json.loads(question.similar_questions)[0]["difficulty"] in ( + "Easy", + "Medium", + "Hard", + ) + assert len(question.contributors) == 0 + assert "python" in list(json.loads(question.lang_to_valid_playground).keys()) + topic_tag = question.topic_tags[0] + assert isinstance(topic_tag, leetcode.GraphqlQuestionTopicTag) + assert len(topic_tag.name) > 0 + assert len(topic_tag.slug) > 0 + assert question.topic_tags[0].translated_name is None + assert len(topic_tag.typename) > 0 + + tag_stat = list(json.loads(question.company_tag_stats).values())[0][0] + + assert tag_stat["taggedByAdmin"] in (True, False) + assert len(tag_stat["name"]) > 0 + assert len(tag_stat["slug"]) > 0 + assert tag_stat["timesEncountered"] > 0 + + code_snippet = question.code_snippets[0] + + assert isinstance(code_snippet, leetcode.GraphqlQuestionCodeSnippet) + assert len(code_snippet.code) > 0 + assert len(code_snippet.lang) > 0 + assert len(code_snippet.lang_slug) > 0 + assert code_snippet.typename == "CodeSnippetNode" + + stats = json.loads(question.stats) + + assert len(stats["totalAccepted"]) > 0 + assert len(stats["totalSubmission"]) > 0 + assert int(stats["totalAcceptedRaw"]) > 0 + assert int(stats["totalSubmissionRaw"]) > 0 + + code_definition = json.loads(question.code_definition)[0] + + assert len(code_definition["value"]) > 0 + assert len(code_definition["text"]) > 0 + assert len(code_definition["defaultCode"]) > 0 + + assert [len(hint) > 0 for hint in question.hints] + + solution = question.solution + + # FIXME: this check doesn't work with swagger generated code + # assert isinstance(solution, leetcode.GraphqlQuestionSolution) + + # FIXME: swagger generates the code which returns dict + assert solution["__typename"] == "ArticleNode" + assert solution["canSeeDetail"] in (True, False) + assert int(solution["id"]) > 0 + + assert question.status in ("ac", "not_started", "tried") + + assert len(question.sample_test_case) > 0 + + assert question.enable_run_code in (True, False) + + meta_data = json.loads(question.meta_data) + + assert meta_data["name"] == "twoSum" + assert meta_data["params"][0]["name"] + assert meta_data["params"][0]["type"] + assert meta_data["return"]["type"] + assert meta_data["return"]["size"] + assert meta_data["manual"] in (True, False) + + assert question.translated_content is None + + assert question.judger_available is True + assert question.judge_type in ("large", "small") + + assert question.mysql_schemas == [] + + assert question.enable_test_mode in (True, False) + + env_info = json.loads(question.env_info) + + assert env_info["cpp"][0] == "C++" diff --git a/test/test_graphql_request_user.py b/test/test_graphql_request_user.py new file mode 100644 index 0000000..0d19102 --- /dev/null +++ b/test/test_graphql_request_user.py @@ -0,0 +1,35 @@ +import json +import test.base + +import leetcode + + +class TestGraphqlGetUser(test.base.BaseTest): + def test_request(self) -> None: + graphql_request = leetcode.GraphqlQuery( + query=""" + { + user { + username + isCurrentUserPremium + } + } + """, + variables=leetcode.GraphqlQueryVariables(), + operation_name="", + ) + + response = self._api_instance.graphql_post(body=graphql_request) + + data = response.data + + assert data + + question = data.question + + assert question is None + + user = data.user + + assert user.username + assert user.is_current_user_premium in (True, False) From 59d35e34d648366f0436932c7d9e3fe2dffd0169 Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Fri, 22 Oct 2021 15:02:43 +0100 Subject: [PATCH 02/24] Bump version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 671c67d..60da0b7 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ from setuptools import find_packages, setup # noqa: H301 NAME = "python-leetcode" -VERSION = "1.0.7" +VERSION = "1.0.8" with open("README.md") as readme: DESCRIPTION = readme.read() From 30fd9266c3afdf9af12f8283426df95174d521b8 Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Fri, 22 Oct 2021 15:13:25 +0100 Subject: [PATCH 03/24] Added missing requirement --- setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 60da0b7..41a991c 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ from setuptools import find_packages, setup # noqa: H301 NAME = "python-leetcode" -VERSION = "1.0.8" +VERSION = "1.0.9" with open("README.md") as readme: DESCRIPTION = readme.read() @@ -24,7 +24,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["urllib3 >= 1.15", "six >= 1.10", "certifi", "python-dateutil"] +REQUIRES = ["urllib3 >= 1.15", "six >= 1.10", "certifi", "python-dateutil", "requests"] setup( name=NAME, @@ -48,5 +48,5 @@ "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", ], - python_requires='>=3.8', + python_requires=">=3.8", ) From f1fc378cc3416e79d5fa811068bcc239894a9f0d Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Fri, 22 Oct 2021 15:34:16 +0100 Subject: [PATCH 04/24] Added new fields to the question details object --- docs/GraphqlQuestionDetail.md | 5 + leetcode/models/graphql_question_detail.py | 132 +++++++++++++++++- ...est_graphql_request_get_question_detail.py | 14 ++ 3 files changed, 150 insertions(+), 1 deletion(-) diff --git a/docs/GraphqlQuestionDetail.md b/docs/GraphqlQuestionDetail.md index 705c35e..c91d96f 100644 --- a/docs/GraphqlQuestionDetail.md +++ b/docs/GraphqlQuestionDetail.md @@ -8,6 +8,7 @@ Name | Type | Description | Notes **bound_topic_id** | **str** | | [optional] **title** | **str** | | [optional] **frequency** | **float** | | [optional] +**freq_bar** | **float** | | [optional] **content** | **str** | | [optional] **translated_title** | **str** | | [optional] **translated_content** | **str** | | [optional] @@ -16,6 +17,7 @@ Name | Type | Description | Notes **likes** | **int** | | [optional] **dislikes** | **int** | | [optional] **is_liked** | **bool** | | [optional] +**is_favor** | **bool** | | [optional] **similar_questions** | **str** | | [optional] **contributors** | [**list[GraphqlQuestionContributor]**](GraphqlQuestionContributor.md) | | [optional] **lang_to_valid_playground** | **str** | | [optional] @@ -23,8 +25,11 @@ Name | Type | Description | Notes **company_tag_stats** | **str** | | [optional] **code_snippets** | [**list[GraphqlQuestionCodeSnippet]**](GraphqlQuestionCodeSnippet.md) | | [optional] **stats** | **str** | | [optional] +**ac_rate** | **float** | | [optional] **hints** | **list[str]** | | [optional] **solution** | [**AnyOfGraphqlQuestionDetailSolution**](AnyOfGraphqlQuestionDetailSolution.md) | | [optional] +**has_solution** | **bool** | | [optional] +**has_video_solution** | **bool** | | [optional] **status** | **str** | | [optional] **sample_test_case** | **str** | | [optional] **judger_available** | **bool** | | [optional] diff --git a/leetcode/models/graphql_question_detail.py b/leetcode/models/graphql_question_detail.py index 2e39762..b699239 100644 --- a/leetcode/models/graphql_question_detail.py +++ b/leetcode/models/graphql_question_detail.py @@ -33,6 +33,7 @@ class GraphqlQuestionDetail(object): 'bound_topic_id': 'str', 'title': 'str', 'frequency': 'float', + 'freq_bar': 'float', 'content': 'str', 'translated_title': 'str', 'translated_content': 'str', @@ -41,6 +42,7 @@ class GraphqlQuestionDetail(object): 'likes': 'int', 'dislikes': 'int', 'is_liked': 'bool', + 'is_favor': 'bool', 'similar_questions': 'str', 'contributors': 'list[GraphqlQuestionContributor]', 'lang_to_valid_playground': 'str', @@ -48,8 +50,11 @@ class GraphqlQuestionDetail(object): 'company_tag_stats': 'str', 'code_snippets': 'list[GraphqlQuestionCodeSnippet]', 'stats': 'str', + 'ac_rate': 'float', 'hints': 'list[str]', 'solution': 'AnyOfGraphqlQuestionDetailSolution', + 'has_solution': 'bool', + 'has_video_solution': 'bool', 'status': 'str', 'sample_test_case': 'str', 'judger_available': 'bool', @@ -68,6 +73,7 @@ class GraphqlQuestionDetail(object): 'bound_topic_id': 'boundTopicId', 'title': 'title', 'frequency': 'frequency', + 'freq_bar': 'freqBar', 'content': 'content', 'translated_title': 'translatedTitle', 'translated_content': 'translatedContent', @@ -76,6 +82,7 @@ class GraphqlQuestionDetail(object): 'likes': 'likes', 'dislikes': 'dislikes', 'is_liked': 'isLiked', + 'is_favor': 'isFavor', 'similar_questions': 'similarQuestions', 'contributors': 'contributors', 'lang_to_valid_playground': 'langToValidPlayground', @@ -83,8 +90,11 @@ class GraphqlQuestionDetail(object): 'company_tag_stats': 'companyTagStats', 'code_snippets': 'codeSnippets', 'stats': 'stats', + 'ac_rate': 'acRate', 'hints': 'hints', 'solution': 'solution', + 'has_solution': 'hasSolution', + 'has_video_solution': 'hasVideoSolution', 'status': 'status', 'sample_test_case': 'sampleTestCase', 'judger_available': 'judgerAvailable', @@ -97,13 +107,14 @@ class GraphqlQuestionDetail(object): 'code_definition': 'codeDefinition' } - def __init__(self, question_id=None, question_frontend_id=None, bound_topic_id=None, title=None, frequency=None, content=None, translated_title=None, translated_content=None, is_paid_only=None, difficulty=None, likes=None, dislikes=None, is_liked=None, similar_questions=None, contributors=None, lang_to_valid_playground=None, topic_tags=None, company_tag_stats=None, code_snippets=None, stats=None, hints=None, solution=None, status=None, sample_test_case=None, judger_available=None, judge_type=None, mysql_schemas=None, enable_run_code=None, enable_test_mode=None, env_info=None, meta_data=None, code_definition=None): # noqa: E501 + def __init__(self, question_id=None, question_frontend_id=None, bound_topic_id=None, title=None, frequency=None, freq_bar=None, content=None, translated_title=None, translated_content=None, is_paid_only=None, difficulty=None, likes=None, dislikes=None, is_liked=None, is_favor=None, similar_questions=None, contributors=None, lang_to_valid_playground=None, topic_tags=None, company_tag_stats=None, code_snippets=None, stats=None, ac_rate=None, hints=None, solution=None, has_solution=None, has_video_solution=None, status=None, sample_test_case=None, judger_available=None, judge_type=None, mysql_schemas=None, enable_run_code=None, enable_test_mode=None, env_info=None, meta_data=None, code_definition=None): # noqa: E501 """GraphqlQuestionDetail - a model defined in Swagger""" # noqa: E501 self._question_id = None self._question_frontend_id = None self._bound_topic_id = None self._title = None self._frequency = None + self._freq_bar = None self._content = None self._translated_title = None self._translated_content = None @@ -112,6 +123,7 @@ def __init__(self, question_id=None, question_frontend_id=None, bound_topic_id=N self._likes = None self._dislikes = None self._is_liked = None + self._is_favor = None self._similar_questions = None self._contributors = None self._lang_to_valid_playground = None @@ -119,8 +131,11 @@ def __init__(self, question_id=None, question_frontend_id=None, bound_topic_id=N self._company_tag_stats = None self._code_snippets = None self._stats = None + self._ac_rate = None self._hints = None self._solution = None + self._has_solution = None + self._has_video_solution = None self._status = None self._sample_test_case = None self._judger_available = None @@ -142,6 +157,8 @@ def __init__(self, question_id=None, question_frontend_id=None, bound_topic_id=N self.title = title if frequency is not None: self.frequency = frequency + if freq_bar is not None: + self.freq_bar = freq_bar if content is not None: self.content = content if translated_title is not None: @@ -158,6 +175,8 @@ def __init__(self, question_id=None, question_frontend_id=None, bound_topic_id=N self.dislikes = dislikes if is_liked is not None: self.is_liked = is_liked + if is_favor is not None: + self.is_favor = is_favor if similar_questions is not None: self.similar_questions = similar_questions if contributors is not None: @@ -172,10 +191,16 @@ def __init__(self, question_id=None, question_frontend_id=None, bound_topic_id=N self.code_snippets = code_snippets if stats is not None: self.stats = stats + if ac_rate is not None: + self.ac_rate = ac_rate if hints is not None: self.hints = hints if solution is not None: self.solution = solution + if has_solution is not None: + self.has_solution = has_solution + if has_video_solution is not None: + self.has_video_solution = has_video_solution if status is not None: self.status = status if sample_test_case is not None: @@ -302,6 +327,27 @@ def frequency(self, frequency): self._frequency = frequency + @property + def freq_bar(self): + """Gets the freq_bar of this GraphqlQuestionDetail. # noqa: E501 + + + :return: The freq_bar of this GraphqlQuestionDetail. # noqa: E501 + :rtype: float + """ + return self._freq_bar + + @freq_bar.setter + def freq_bar(self, freq_bar): + """Sets the freq_bar of this GraphqlQuestionDetail. + + + :param freq_bar: The freq_bar of this GraphqlQuestionDetail. # noqa: E501 + :type: float + """ + + self._freq_bar = freq_bar + @property def content(self): """Gets the content of this GraphqlQuestionDetail. # noqa: E501 @@ -470,6 +516,27 @@ def is_liked(self, is_liked): self._is_liked = is_liked + @property + def is_favor(self): + """Gets the is_favor of this GraphqlQuestionDetail. # noqa: E501 + + + :return: The is_favor of this GraphqlQuestionDetail. # noqa: E501 + :rtype: bool + """ + return self._is_favor + + @is_favor.setter + def is_favor(self, is_favor): + """Sets the is_favor of this GraphqlQuestionDetail. + + + :param is_favor: The is_favor of this GraphqlQuestionDetail. # noqa: E501 + :type: bool + """ + + self._is_favor = is_favor + @property def similar_questions(self): """Gets the similar_questions of this GraphqlQuestionDetail. # noqa: E501 @@ -617,6 +684,27 @@ def stats(self, stats): self._stats = stats + @property + def ac_rate(self): + """Gets the ac_rate of this GraphqlQuestionDetail. # noqa: E501 + + + :return: The ac_rate of this GraphqlQuestionDetail. # noqa: E501 + :rtype: float + """ + return self._ac_rate + + @ac_rate.setter + def ac_rate(self, ac_rate): + """Sets the ac_rate of this GraphqlQuestionDetail. + + + :param ac_rate: The ac_rate of this GraphqlQuestionDetail. # noqa: E501 + :type: float + """ + + self._ac_rate = ac_rate + @property def hints(self): """Gets the hints of this GraphqlQuestionDetail. # noqa: E501 @@ -659,6 +747,48 @@ def solution(self, solution): self._solution = solution + @property + def has_solution(self): + """Gets the has_solution of this GraphqlQuestionDetail. # noqa: E501 + + + :return: The has_solution of this GraphqlQuestionDetail. # noqa: E501 + :rtype: bool + """ + return self._has_solution + + @has_solution.setter + def has_solution(self, has_solution): + """Sets the has_solution of this GraphqlQuestionDetail. + + + :param has_solution: The has_solution of this GraphqlQuestionDetail. # noqa: E501 + :type: bool + """ + + self._has_solution = has_solution + + @property + def has_video_solution(self): + """Gets the has_video_solution of this GraphqlQuestionDetail. # noqa: E501 + + + :return: The has_video_solution of this GraphqlQuestionDetail. # noqa: E501 + :rtype: bool + """ + return self._has_video_solution + + @has_video_solution.setter + def has_video_solution(self, has_video_solution): + """Sets the has_video_solution of this GraphqlQuestionDetail. + + + :param has_video_solution: The has_video_solution of this GraphqlQuestionDetail. # noqa: E501 + :type: bool + """ + + self._has_video_solution = has_video_solution + @property def status(self): """Gets the status of this GraphqlQuestionDetail. # noqa: E501 diff --git a/test/test_graphql_request_get_question_detail.py b/test/test_graphql_request_get_question_detail.py index 34873d8..dd7c5af 100644 --- a/test/test_graphql_request_get_question_detail.py +++ b/test/test_graphql_request_get_question_detail.py @@ -14,6 +14,8 @@ def test_request(self) -> None: questionFrontendId boundTopicId title + frequency + freqBar content translatedTitle isPaidOnly @@ -21,6 +23,7 @@ def test_request(self) -> None: likes dislikes isLiked + isFavor similarQuestions contributors { username @@ -43,6 +46,7 @@ def test_request(self) -> None: __typename } stats + acRate codeDefinition hints solution { @@ -50,6 +54,8 @@ def test_request(self) -> None: canSeeDetail __typename } + hasSolution + hasVideoSolution status sampleTestCase enableRunCode @@ -83,6 +89,8 @@ def test_request(self) -> None: assert question.question_frontend_id == "1" assert question.bound_topic_id is None assert question.title == "Two Sum" + assert question.frequency == 0.0 + assert question.freq_bar > 0 assert len(question.content) > 10 assert question.translated_title is None assert question.is_paid_only is False @@ -90,6 +98,7 @@ def test_request(self) -> None: assert question.likes > 0 assert question.dislikes > 0 assert question.is_liked is None + assert question.is_favor in (True, False) assert json.loads(question.similar_questions)[0]["difficulty"] in ( "Easy", "Medium", @@ -126,6 +135,8 @@ def test_request(self) -> None: assert int(stats["totalAcceptedRaw"]) > 0 assert int(stats["totalSubmissionRaw"]) > 0 + assert question.ac_rate > 0 + code_definition = json.loads(question.code_definition)[0] assert len(code_definition["value"]) > 0 @@ -144,6 +155,9 @@ def test_request(self) -> None: assert solution["canSeeDetail"] in (True, False) assert int(solution["id"]) > 0 + assert question.has_solution in (True, False) + assert question.has_video_solution in (True, False) + assert question.status in ("ac", "not_started", "tried") assert len(question.sample_test_case) > 0 From dd7bf56f2a7701ef53b636f1f98bd55419d3c101 Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Fri, 22 Oct 2021 15:45:38 +0100 Subject: [PATCH 05/24] Version bump --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 41a991c..c7d9d86 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ from setuptools import find_packages, setup # noqa: H301 NAME = "python-leetcode" -VERSION = "1.0.9" +VERSION = "1.0.10" with open("README.md") as readme: DESCRIPTION = readme.read() From f7605202fd8c17aa61b6f7f420d1de17ae937714 Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Sat, 23 Oct 2021 00:43:42 +0100 Subject: [PATCH 06/24] Black + isort on the repo --- .isort.cfg | 7 + example.py | 3 +- leetcode/__init__.py | 6 +- leetcode/api/__init__.py | 4 +- leetcode/api/default_api.py | 351 +++++++++------ leetcode/api_client.py | 409 +++++++++++------- leetcode/configuration.py | 75 ++-- leetcode/models/__init__.py | 4 +- ...any_of_graphql_question_detail_solution.py | 28 +- leetcode/models/base_submission_result.py | 180 +++++--- leetcode/models/difficulty.py | 34 +- leetcode/models/graphql_data.py | 32 +- leetcode/models/graphql_query.py | 42 +- leetcode/models/graphql_query_variables.py | 30 +- .../models/graphql_question_code_snippet.py | 54 ++- .../models/graphql_question_contributor.py | 54 ++- leetcode/models/graphql_question_detail.py | 211 +++++---- leetcode/models/graphql_question_solution.py | 42 +- leetcode/models/graphql_question_topic_tag.py | 50 ++- leetcode/models/graphql_response.py | 34 +- leetcode/models/graphql_user.py | 31 +- leetcode/models/id.py | 28 +- leetcode/models/inline_response200.py | 28 +- leetcode/models/interpretation.py | 40 +- leetcode/models/one_ofid.py | 28 +- leetcode/models/one_ofinline_response200.py | 28 +- leetcode/models/problems.py | 116 +++-- leetcode/models/stat.py | 125 ++++-- leetcode/models/stat_status_pair.py | 85 ++-- leetcode/models/submission.py | 76 ++-- leetcode/models/submission_id.py | 34 +- leetcode/models/submission_result.py | 87 ++-- leetcode/models/test_submission.py | 71 +-- leetcode/models/test_submission_result.py | 97 +++-- leetcode/rest.py | 302 ++++++++----- setup.generated.py | 4 +- ...any_of_graphql_question_detail_solution.py | 6 +- test/test_base_submission_result.py | 2 +- test/test_default_api.py | 22 +- test/test_difficulty.py | 2 +- test/test_graphql_data.py | 2 +- test/test_graphql_query.py | 2 +- test/test_graphql_query_variables.py | 2 +- test/test_graphql_question_code_snippet.py | 6 +- test/test_graphql_question_contributor.py | 6 +- test/test_graphql_question_detail.py | 2 +- test/test_graphql_question_solution.py | 6 +- test/test_graphql_question_topic_tag.py | 6 +- test/test_graphql_response.py | 2 +- test/test_graphql_user.py | 2 +- test/test_id.py | 2 +- test/test_inline_response200.py | 2 +- test/test_interpretation.py | 2 +- test/test_one_ofid.py | 2 +- test/test_one_ofinline_response200.py | 6 +- test/test_problems.py | 2 +- test/test_stat.py | 2 +- test/test_stat_status_pair.py | 2 +- test/test_submission.py | 2 +- test/test_submission_id.py | 2 +- test/test_submission_result.py | 2 +- test/test_test_submission.py | 2 +- test/test_test_submission_result.py | 2 +- 63 files changed, 1769 insertions(+), 1159 deletions(-) create mode 100644 .isort.cfg diff --git a/.isort.cfg b/.isort.cfg new file mode 100644 index 0000000..b130d96 --- /dev/null +++ b/.isort.cfg @@ -0,0 +1,7 @@ +[settings] +force_grid_wrap=0 +include_trailing_comma=True +line_length=88 +multi_line_output=3 +use_parentheses=True +ensure_newline_before_comments=True diff --git a/example.py b/example.py index 964808b..0751534 100644 --- a/example.py +++ b/example.py @@ -1,9 +1,10 @@ import sys from time import sleep -import leetcode from cookies import cookies +import leetcode + # Initialize client configuration = leetcode.Configuration() diff --git a/leetcode/__init__.py b/leetcode/__init__.py index 63a296d..0bd925d 100644 --- a/leetcode/__init__.py +++ b/leetcode/__init__.py @@ -16,11 +16,15 @@ # import apis into sdk package from leetcode.api.default_api import DefaultApi + # import ApiClient from leetcode.api_client import ApiClient from leetcode.configuration import Configuration + # import models into sdk package -from leetcode.models.any_of_graphql_question_detail_solution import AnyOfGraphqlQuestionDetailSolution +from leetcode.models.any_of_graphql_question_detail_solution import ( + AnyOfGraphqlQuestionDetailSolution, +) from leetcode.models.base_submission_result import BaseSubmissionResult from leetcode.models.difficulty import Difficulty from leetcode.models.graphql_data import GraphqlData diff --git a/leetcode/api/__init__.py b/leetcode/api/__init__.py index 1f1110c..ff2adc1 100644 --- a/leetcode/api/__init__.py +++ b/leetcode/api/__init__.py @@ -1,6 +1,6 @@ from __future__ import absolute_import -# flake8: noqa - # import apis into api package from leetcode.api.default_api import DefaultApi + +# flake8: noqa diff --git a/leetcode/api/default_api.py b/leetcode/api/default_api.py index 5dbd976..d1a8e01 100644 --- a/leetcode/api/default_api.py +++ b/leetcode/api/default_api.py @@ -46,11 +46,15 @@ def api_problems_topic_get(self, topic, **kwargs): # noqa: E501 If the method is called asynchronously, returns the request thread. """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.api_problems_topic_get_with_http_info(topic, **kwargs) # noqa: E501 + kwargs["_return_http_data_only"] = True + if kwargs.get("async_req"): + return self.api_problems_topic_get_with_http_info( + topic, **kwargs + ) # noqa: E501 else: - (data) = self.api_problems_topic_get_with_http_info(topic, **kwargs) # noqa: E501 + (data) = self.api_problems_topic_get_with_http_info( + topic, **kwargs + ) # noqa: E501 return data def api_problems_topic_get_with_http_info(self, topic, **kwargs): # noqa: E501 @@ -68,31 +72,32 @@ def api_problems_topic_get_with_http_info(self, topic, **kwargs): # noqa: E501 returns the request thread. """ - all_params = ['topic'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ["topic"] # noqa: E501 + all_params.append("async_req") + all_params.append("_return_http_data_only") + all_params.append("_preload_content") + all_params.append("_request_timeout") params = locals() - for key, val in six.iteritems(params['kwargs']): + for key, val in six.iteritems(params["kwargs"]): if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" " to method api_problems_topic_get" % key ) params[key] = val - del params['kwargs'] + del params["kwargs"] # verify the required parameter 'topic' is set - if ('topic' not in params or - params['topic'] is None): - raise ValueError("Missing the required parameter `topic` when calling `api_problems_topic_get`") # noqa: E501 + if "topic" not in params or params["topic"] is None: + raise ValueError( + "Missing the required parameter `topic` when calling `api_problems_topic_get`" + ) # noqa: E501 collection_formats = {} path_params = {} - if 'topic' in params: - path_params['topic'] = params['topic'] # noqa: E501 + if "topic" in params: + path_params["topic"] = params["topic"] # noqa: E501 query_params = [] @@ -103,27 +108,35 @@ def api_problems_topic_get_with_http_info(self, topic, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # noqa: E501 # Authentication setting - auth_settings = ['cookieCSRF', 'cookieSession', 'headerCSRF', 'referer'] # noqa: E501 + auth_settings = [ + "cookieCSRF", + "cookieSession", + "headerCSRF", + "referer", + ] # noqa: E501 return self.api_client.call_api( - '/api/problems/{topic}/', 'GET', + "/api/problems/{topic}/", + "GET", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='Problems', # noqa: E501 + response_type="Problems", # noqa: E501 auth_settings=auth_settings, - async_req=params.get('async_req'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) + async_req=params.get("async_req"), + _return_http_data_only=params.get("_return_http_data_only"), + _preload_content=params.get("_preload_content", True), + _request_timeout=params.get("_request_timeout"), + collection_formats=collection_formats, + ) def graphql_post(self, **kwargs): # noqa: E501 """graphql_post # noqa: E501 @@ -139,8 +152,8 @@ def graphql_post(self, **kwargs): # noqa: E501 If the method is called asynchronously, returns the request thread. """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): + kwargs["_return_http_data_only"] = True + if kwargs.get("async_req"): return self.graphql_post_with_http_info(**kwargs) # noqa: E501 else: (data) = self.graphql_post_with_http_info(**kwargs) # noqa: E501 @@ -161,21 +174,21 @@ def graphql_post_with_http_info(self, **kwargs): # noqa: E501 returns the request thread. """ - all_params = ['body'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ["body"] # noqa: E501 + all_params.append("async_req") + all_params.append("_return_http_data_only") + all_params.append("_preload_content") + all_params.append("_request_timeout") params = locals() - for key, val in six.iteritems(params['kwargs']): + for key, val in six.iteritems(params["kwargs"]): if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" " to method graphql_post" % key ) params[key] = val - del params['kwargs'] + del params["kwargs"] collection_formats = {} @@ -189,34 +202,45 @@ def graphql_post_with_http_info(self, **kwargs): # noqa: E501 local_var_files = {} body_params = None - if 'body' in params: - body_params = params['body'] + if "body" in params: + body_params = params["body"] # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + header_params[ + "Content-Type" + ] = self.api_client.select_header_content_type( # noqa: E501 + ["application/json"] + ) # noqa: E501 # Authentication setting - auth_settings = ['cookieCSRF', 'cookieSession', 'headerCSRF', 'referer'] # noqa: E501 + auth_settings = [ + "cookieCSRF", + "cookieSession", + "headerCSRF", + "referer", + ] # noqa: E501 return self.api_client.call_api( - '/graphql', 'POST', + "/graphql", + "POST", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='GraphqlResponse', # noqa: E501 + response_type="GraphqlResponse", # noqa: E501 auth_settings=auth_settings, - async_req=params.get('async_req'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) + async_req=params.get("async_req"), + _return_http_data_only=params.get("_return_http_data_only"), + _preload_content=params.get("_preload_content", True), + _request_timeout=params.get("_request_timeout"), + collection_formats=collection_formats, + ) def problems_problem_interpret_solution_post(self, problem, **kwargs): # noqa: E501 """problems_problem_interpret_solution_post # noqa: E501 @@ -233,14 +257,20 @@ def problems_problem_interpret_solution_post(self, problem, **kwargs): # noqa: If the method is called asynchronously, returns the request thread. """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.problems_problem_interpret_solution_post_with_http_info(problem, **kwargs) # noqa: E501 + kwargs["_return_http_data_only"] = True + if kwargs.get("async_req"): + return self.problems_problem_interpret_solution_post_with_http_info( + problem, **kwargs + ) # noqa: E501 else: - (data) = self.problems_problem_interpret_solution_post_with_http_info(problem, **kwargs) # noqa: E501 + (data) = self.problems_problem_interpret_solution_post_with_http_info( + problem, **kwargs + ) # noqa: E501 return data - def problems_problem_interpret_solution_post_with_http_info(self, problem, **kwargs): # noqa: E501 + def problems_problem_interpret_solution_post_with_http_info( + self, problem, **kwargs + ): # noqa: E501 """problems_problem_interpret_solution_post # noqa: E501 This method makes a synchronous HTTP request by default. To make an @@ -256,31 +286,32 @@ def problems_problem_interpret_solution_post_with_http_info(self, problem, **kwa returns the request thread. """ - all_params = ['problem', 'body'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ["problem", "body"] # noqa: E501 + all_params.append("async_req") + all_params.append("_return_http_data_only") + all_params.append("_preload_content") + all_params.append("_request_timeout") params = locals() - for key, val in six.iteritems(params['kwargs']): + for key, val in six.iteritems(params["kwargs"]): if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" " to method problems_problem_interpret_solution_post" % key ) params[key] = val - del params['kwargs'] + del params["kwargs"] # verify the required parameter 'problem' is set - if ('problem' not in params or - params['problem'] is None): - raise ValueError("Missing the required parameter `problem` when calling `problems_problem_interpret_solution_post`") # noqa: E501 + if "problem" not in params or params["problem"] is None: + raise ValueError( + "Missing the required parameter `problem` when calling `problems_problem_interpret_solution_post`" + ) # noqa: E501 collection_formats = {} path_params = {} - if 'problem' in params: - path_params['problem'] = params['problem'] # noqa: E501 + if "problem" in params: + path_params["problem"] = params["problem"] # noqa: E501 query_params = [] @@ -290,34 +321,45 @@ def problems_problem_interpret_solution_post_with_http_info(self, problem, **kwa local_var_files = {} body_params = None - if 'body' in params: - body_params = params['body'] + if "body" in params: + body_params = params["body"] # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + header_params[ + "Content-Type" + ] = self.api_client.select_header_content_type( # noqa: E501 + ["application/json"] + ) # noqa: E501 # Authentication setting - auth_settings = ['cookieCSRF', 'cookieSession', 'headerCSRF', 'referer'] # noqa: E501 + auth_settings = [ + "cookieCSRF", + "cookieSession", + "headerCSRF", + "referer", + ] # noqa: E501 return self.api_client.call_api( - '/problems/{problem}/interpret_solution/', 'POST', + "/problems/{problem}/interpret_solution/", + "POST", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='Interpretation', # noqa: E501 + response_type="Interpretation", # noqa: E501 auth_settings=auth_settings, - async_req=params.get('async_req'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) + async_req=params.get("async_req"), + _return_http_data_only=params.get("_return_http_data_only"), + _preload_content=params.get("_preload_content", True), + _request_timeout=params.get("_request_timeout"), + collection_formats=collection_formats, + ) def problems_problem_submit_post(self, problem, **kwargs): # noqa: E501 """problems_problem_submit_post # noqa: E501 @@ -334,14 +376,20 @@ def problems_problem_submit_post(self, problem, **kwargs): # noqa: E501 If the method is called asynchronously, returns the request thread. """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.problems_problem_submit_post_with_http_info(problem, **kwargs) # noqa: E501 + kwargs["_return_http_data_only"] = True + if kwargs.get("async_req"): + return self.problems_problem_submit_post_with_http_info( + problem, **kwargs + ) # noqa: E501 else: - (data) = self.problems_problem_submit_post_with_http_info(problem, **kwargs) # noqa: E501 + (data) = self.problems_problem_submit_post_with_http_info( + problem, **kwargs + ) # noqa: E501 return data - def problems_problem_submit_post_with_http_info(self, problem, **kwargs): # noqa: E501 + def problems_problem_submit_post_with_http_info( + self, problem, **kwargs + ): # noqa: E501 """problems_problem_submit_post # noqa: E501 This method makes a synchronous HTTP request by default. To make an @@ -357,31 +405,32 @@ def problems_problem_submit_post_with_http_info(self, problem, **kwargs): # noq returns the request thread. """ - all_params = ['problem', 'body'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ["problem", "body"] # noqa: E501 + all_params.append("async_req") + all_params.append("_return_http_data_only") + all_params.append("_preload_content") + all_params.append("_request_timeout") params = locals() - for key, val in six.iteritems(params['kwargs']): + for key, val in six.iteritems(params["kwargs"]): if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" " to method problems_problem_submit_post" % key ) params[key] = val - del params['kwargs'] + del params["kwargs"] # verify the required parameter 'problem' is set - if ('problem' not in params or - params['problem'] is None): - raise ValueError("Missing the required parameter `problem` when calling `problems_problem_submit_post`") # noqa: E501 + if "problem" not in params or params["problem"] is None: + raise ValueError( + "Missing the required parameter `problem` when calling `problems_problem_submit_post`" + ) # noqa: E501 collection_formats = {} path_params = {} - if 'problem' in params: - path_params['problem'] = params['problem'] # noqa: E501 + if "problem" in params: + path_params["problem"] = params["problem"] # noqa: E501 query_params = [] @@ -391,34 +440,45 @@ def problems_problem_submit_post_with_http_info(self, problem, **kwargs): # noq local_var_files = {} body_params = None - if 'body' in params: - body_params = params['body'] + if "body" in params: + body_params = params["body"] # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + header_params[ + "Content-Type" + ] = self.api_client.select_header_content_type( # noqa: E501 + ["application/json"] + ) # noqa: E501 # Authentication setting - auth_settings = ['cookieCSRF', 'cookieSession', 'headerCSRF', 'referer'] # noqa: E501 + auth_settings = [ + "cookieCSRF", + "cookieSession", + "headerCSRF", + "referer", + ] # noqa: E501 return self.api_client.call_api( - '/problems/{problem}/submit/', 'POST', + "/problems/{problem}/submit/", + "POST", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='SubmissionId', # noqa: E501 + response_type="SubmissionId", # noqa: E501 auth_settings=auth_settings, - async_req=params.get('async_req'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) + async_req=params.get("async_req"), + _return_http_data_only=params.get("_return_http_data_only"), + _preload_content=params.get("_preload_content", True), + _request_timeout=params.get("_request_timeout"), + collection_formats=collection_formats, + ) def submissions_detail_id_check_get(self, id, **kwargs): # noqa: E501 """submissions_detail_id_check_get # noqa: E501 @@ -434,14 +494,20 @@ def submissions_detail_id_check_get(self, id, **kwargs): # noqa: E501 If the method is called asynchronously, returns the request thread. """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.submissions_detail_id_check_get_with_http_info(id, **kwargs) # noqa: E501 + kwargs["_return_http_data_only"] = True + if kwargs.get("async_req"): + return self.submissions_detail_id_check_get_with_http_info( + id, **kwargs + ) # noqa: E501 else: - (data) = self.submissions_detail_id_check_get_with_http_info(id, **kwargs) # noqa: E501 + (data) = self.submissions_detail_id_check_get_with_http_info( + id, **kwargs + ) # noqa: E501 return data - def submissions_detail_id_check_get_with_http_info(self, id, **kwargs): # noqa: E501 + def submissions_detail_id_check_get_with_http_info( + self, id, **kwargs + ): # noqa: E501 """submissions_detail_id_check_get # noqa: E501 This method makes a synchronous HTTP request by default. To make an @@ -456,31 +522,32 @@ def submissions_detail_id_check_get_with_http_info(self, id, **kwargs): # noqa: returns the request thread. """ - all_params = ['id'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ["id"] # noqa: E501 + all_params.append("async_req") + all_params.append("_return_http_data_only") + all_params.append("_preload_content") + all_params.append("_request_timeout") params = locals() - for key, val in six.iteritems(params['kwargs']): + for key, val in six.iteritems(params["kwargs"]): if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" " to method submissions_detail_id_check_get" % key ) params[key] = val - del params['kwargs'] + del params["kwargs"] # verify the required parameter 'id' is set - if ('id' not in params or - params['id'] is None): - raise ValueError("Missing the required parameter `id` when calling `submissions_detail_id_check_get`") # noqa: E501 + if "id" not in params or params["id"] is None: + raise ValueError( + "Missing the required parameter `id` when calling `submissions_detail_id_check_get`" + ) # noqa: E501 collection_formats = {} path_params = {} - if 'id' in params: - path_params['id'] = params['id'] # noqa: E501 + if "id" in params: + path_params["id"] = params["id"] # noqa: E501 query_params = [] @@ -491,24 +558,32 @@ def submissions_detail_id_check_get_with_http_info(self, id, **kwargs): # noqa: body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # noqa: E501 # Authentication setting - auth_settings = ['cookieCSRF', 'cookieSession', 'headerCSRF', 'referer'] # noqa: E501 + auth_settings = [ + "cookieCSRF", + "cookieSession", + "headerCSRF", + "referer", + ] # noqa: E501 return self.api_client.call_api( - '/submissions/detail/{id}/check/', 'GET', + "/submissions/detail/{id}/check/", + "GET", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='InlineResponse200', # noqa: E501 + response_type="InlineResponse200", # noqa: E501 auth_settings=auth_settings, - async_req=params.get('async_req'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) + async_req=params.get("async_req"), + _return_http_data_only=params.get("_return_http_data_only"), + _preload_content=params.get("_preload_content", True), + _request_timeout=params.get("_request_timeout"), + collection_formats=collection_formats, + ) diff --git a/leetcode/api_client.py b/leetcode/api_client.py index 8092ae5..5b7a8f5 100644 --- a/leetcode/api_client.py +++ b/leetcode/api_client.py @@ -14,18 +14,18 @@ import datetime import json import mimetypes -from multiprocessing.pool import ThreadPool import os import re import tempfile +from multiprocessing.pool import ThreadPool # python 2 and python 3 compatibility library import six from six.moves.urllib.parse import quote -from leetcode.configuration import Configuration import leetcode.models from leetcode import rest +from leetcode.configuration import Configuration class ApiClient(object): @@ -50,18 +50,19 @@ class ApiClient(object): PRIMITIVE_TYPES = (float, bool, bytes, six.text_type) + six.integer_types NATIVE_TYPES_MAPPING = { - 'int': int, - 'long': int if six.PY3 else long, # noqa: F821 - 'float': float, - 'str': str, - 'bool': bool, - 'date': datetime.date, - 'datetime': datetime.datetime, - 'object': object, + "int": int, + "long": int if six.PY3 else long, # noqa: F821 + "float": float, + "str": str, + "bool": bool, + "date": datetime.date, + "datetime": datetime.datetime, + "object": object, } - def __init__(self, configuration=None, header_name=None, header_value=None, - cookie=None): + def __init__( + self, configuration=None, header_name=None, header_value=None, cookie=None + ): if configuration is None: configuration = Configuration() self.configuration = configuration @@ -74,7 +75,7 @@ def __init__(self, configuration=None, header_name=None, header_value=None, self.default_headers[header_name] = header_value self.cookie = cookie # Set default User-Agent. - self.user_agent = 'Swagger-Codegen/1.0.0/python' + self.user_agent = "Swagger-Codegen/1.0.0/python" def _close_pool(self): self.pool.close() @@ -83,21 +84,32 @@ def _close_pool(self): @property def user_agent(self): """User agent for this API client""" - return self.default_headers['User-Agent'] + return self.default_headers["User-Agent"] @user_agent.setter def user_agent(self, value): - self.default_headers['User-Agent'] = value + self.default_headers["User-Agent"] = value def set_default_header(self, header_name, header_value): self.default_headers[header_name] = header_value def __call_api( - self, resource_path, method, path_params=None, - query_params=None, header_params=None, body=None, post_params=None, - files=None, response_type=None, auth_settings=None, - _return_http_data_only=None, collection_formats=None, - _preload_content=True, _request_timeout=None): + self, + resource_path, + method, + path_params=None, + query_params=None, + header_params=None, + body=None, + post_params=None, + files=None, + response_type=None, + auth_settings=None, + _return_http_data_only=None, + collection_formats=None, + _preload_content=True, + _request_timeout=None, + ): config = self.configuration @@ -105,36 +117,33 @@ def __call_api( header_params = header_params or {} header_params.update(self.default_headers) if self.cookie: - header_params['Cookie'] = self.cookie + header_params["Cookie"] = self.cookie if header_params: header_params = self.sanitize_for_serialization(header_params) - header_params = dict(self.parameters_to_tuples(header_params, - collection_formats)) + header_params = dict( + self.parameters_to_tuples(header_params, collection_formats) + ) # path parameters if path_params: path_params = self.sanitize_for_serialization(path_params) - path_params = self.parameters_to_tuples(path_params, - collection_formats) + path_params = self.parameters_to_tuples(path_params, collection_formats) for k, v in path_params: # specified safe chars, encode everything resource_path = resource_path.replace( - '{%s}' % k, - quote(str(v), safe=config.safe_chars_for_path_param) + "{%s}" % k, quote(str(v), safe=config.safe_chars_for_path_param) ) # query parameters if query_params: query_params = self.sanitize_for_serialization(query_params) - query_params = self.parameters_to_tuples(query_params, - collection_formats) + query_params = self.parameters_to_tuples(query_params, collection_formats) # post parameters if post_params or files: post_params = self.prepare_post_parameters(post_params, files) post_params = self.sanitize_for_serialization(post_params) - post_params = self.parameters_to_tuples(post_params, - collection_formats) + post_params = self.parameters_to_tuples(post_params, collection_formats) # auth setting self.update_params_for_auth(header_params, query_params, auth_settings) @@ -148,10 +157,15 @@ def __call_api( # perform request and return response response_data = self.request( - method, url, query_params=query_params, headers=header_params, - post_params=post_params, body=body, + method, + url, + query_params=query_params, + headers=header_params, + post_params=post_params, + body=body, _preload_content=_preload_content, - _request_timeout=_request_timeout) + _request_timeout=_request_timeout, + ) self.last_response = response_data @@ -164,10 +178,9 @@ def __call_api( return_data = None if _return_http_data_only: - return (return_data) + return return_data else: - return (return_data, response_data.status, - response_data.getheaders()) + return (return_data, response_data.status, response_data.getheaders()) def sanitize_for_serialization(self, obj): """Builds a JSON POST object. @@ -188,11 +201,9 @@ def sanitize_for_serialization(self, obj): elif isinstance(obj, self.PRIMITIVE_TYPES): return obj elif isinstance(obj, list): - return [self.sanitize_for_serialization(sub_obj) - for sub_obj in obj] + return [self.sanitize_for_serialization(sub_obj) for sub_obj in obj] elif isinstance(obj, tuple): - return tuple(self.sanitize_for_serialization(sub_obj) - for sub_obj in obj) + return tuple(self.sanitize_for_serialization(sub_obj) for sub_obj in obj) elif isinstance(obj, (datetime.datetime, datetime.date)): return obj.isoformat() @@ -204,12 +215,16 @@ def sanitize_for_serialization(self, obj): # and attributes which value is not None. # Convert attribute name to json key in # model definition for request. - obj_dict = {obj.attribute_map[attr]: getattr(obj, attr) - for attr, _ in six.iteritems(obj.swagger_types) - if getattr(obj, attr) is not None} + obj_dict = { + obj.attribute_map[attr]: getattr(obj, attr) + for attr, _ in six.iteritems(obj.swagger_types) + if getattr(obj, attr) is not None + } - return {key: self.sanitize_for_serialization(val) - for key, val in six.iteritems(obj_dict)} + return { + key: self.sanitize_for_serialization(val) + for key, val in six.iteritems(obj_dict) + } def deserialize(self, response, response_type): """Deserializes response into an object. @@ -245,15 +260,15 @@ def __deserialize(self, data, klass): return None if type(klass) == str: - if klass.startswith('list['): - sub_kls = re.match(r'list\[(.*)\]', klass).group(1) - return [self.__deserialize(sub_data, sub_kls) - for sub_data in data] + if klass.startswith("list["): + sub_kls = re.match(r"list\[(.*)\]", klass).group(1) + return [self.__deserialize(sub_data, sub_kls) for sub_data in data] - if klass.startswith('dict('): - sub_kls = re.match(r'dict\(([^,]*), (.*)\)', klass).group(2) - return {k: self.__deserialize(v, sub_kls) - for k, v in six.iteritems(data)} + if klass.startswith("dict("): + sub_kls = re.match(r"dict\(([^,]*), (.*)\)", klass).group(2) + return { + k: self.__deserialize(v, sub_kls) for k, v in six.iteritems(data) + } # convert str to class if klass in self.NATIVE_TYPES_MAPPING: @@ -272,12 +287,24 @@ def __deserialize(self, data, klass): else: return self.__deserialize_model(data, klass) - def call_api(self, resource_path, method, - path_params=None, query_params=None, header_params=None, - body=None, post_params=None, files=None, - response_type=None, auth_settings=None, async_req=None, - _return_http_data_only=None, collection_formats=None, - _preload_content=True, _request_timeout=None): + def call_api( + self, + resource_path, + method, + path_params=None, + query_params=None, + header_params=None, + body=None, + post_params=None, + files=None, + response_type=None, + auth_settings=None, + async_req=None, + _return_http_data_only=None, + collection_formats=None, + _preload_content=True, + _request_timeout=None, + ): """Makes the HTTP request (synchronous) and returns deserialized data. To make an async request, set the async_req parameter. @@ -315,78 +342,121 @@ def call_api(self, resource_path, method, then the method will return the response directly. """ if not async_req: - return self.__call_api(resource_path, method, - path_params, query_params, header_params, - body, post_params, files, - response_type, auth_settings, - _return_http_data_only, collection_formats, - _preload_content, _request_timeout) + return self.__call_api( + resource_path, + method, + path_params, + query_params, + header_params, + body, + post_params, + files, + response_type, + auth_settings, + _return_http_data_only, + collection_formats, + _preload_content, + _request_timeout, + ) else: - thread = self.pool.apply_async(self.__call_api, (resource_path, - method, path_params, query_params, - header_params, body, - post_params, files, - response_type, auth_settings, - _return_http_data_only, - collection_formats, - _preload_content, _request_timeout)) + thread = self.pool.apply_async( + self.__call_api, + ( + resource_path, + method, + path_params, + query_params, + header_params, + body, + post_params, + files, + response_type, + auth_settings, + _return_http_data_only, + collection_formats, + _preload_content, + _request_timeout, + ), + ) return thread - def request(self, method, url, query_params=None, headers=None, - post_params=None, body=None, _preload_content=True, - _request_timeout=None): + def request( + self, + method, + url, + query_params=None, + headers=None, + post_params=None, + body=None, + _preload_content=True, + _request_timeout=None, + ): """Makes the HTTP request using RESTClient.""" if method == "GET": - return self.rest_client.GET(url, - query_params=query_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - headers=headers) + return self.rest_client.GET( + url, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + headers=headers, + ) elif method == "HEAD": - return self.rest_client.HEAD(url, - query_params=query_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - headers=headers) + return self.rest_client.HEAD( + url, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + headers=headers, + ) elif method == "OPTIONS": - return self.rest_client.OPTIONS(url, - query_params=query_params, - headers=headers, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) + return self.rest_client.OPTIONS( + url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body, + ) elif method == "POST": - return self.rest_client.POST(url, - query_params=query_params, - headers=headers, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) + return self.rest_client.POST( + url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body, + ) elif method == "PUT": - return self.rest_client.PUT(url, - query_params=query_params, - headers=headers, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) + return self.rest_client.PUT( + url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body, + ) elif method == "PATCH": - return self.rest_client.PATCH(url, - query_params=query_params, - headers=headers, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) + return self.rest_client.PATCH( + url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body, + ) elif method == "DELETE": - return self.rest_client.DELETE(url, - query_params=query_params, - headers=headers, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) + return self.rest_client.DELETE( + url, + query_params=query_params, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body, + ) else: raise ValueError( "http method must be `GET`, `HEAD`, `OPTIONS`," @@ -403,22 +473,23 @@ def parameters_to_tuples(self, params, collection_formats): new_params = [] if collection_formats is None: collection_formats = {} - for k, v in six.iteritems(params) if isinstance(params, dict) else params: # noqa: E501 + for k, v in ( + six.iteritems(params) if isinstance(params, dict) else params + ): # noqa: E501 if k in collection_formats: collection_format = collection_formats[k] - if collection_format == 'multi': + if collection_format == "multi": new_params.extend((k, value) for value in v) else: - if collection_format == 'ssv': - delimiter = ' ' - elif collection_format == 'tsv': - delimiter = '\t' - elif collection_format == 'pipes': - delimiter = '|' + if collection_format == "ssv": + delimiter = " " + elif collection_format == "tsv": + delimiter = "\t" + elif collection_format == "pipes": + delimiter = "|" else: # csv is the default - delimiter = ',' - new_params.append( - (k, delimiter.join(str(value) for value in v))) + delimiter = "," + new_params.append((k, delimiter.join(str(value) for value in v))) else: new_params.append((k, v)) return new_params @@ -441,13 +512,14 @@ def prepare_post_parameters(self, post_params=None, files=None): continue file_names = v if type(v) is list else [v] for n in file_names: - with open(n, 'rb') as f: + with open(n, "rb") as f: filename = os.path.basename(f.name) filedata = f.read() - mimetype = (mimetypes.guess_type(filename)[0] or - 'application/octet-stream') - params.append( - tuple([k, tuple([filename, filedata, mimetype])])) + mimetype = ( + mimetypes.guess_type(filename)[0] + or "application/octet-stream" + ) + params.append(tuple([k, tuple([filename, filedata, mimetype])])) return params @@ -462,10 +534,10 @@ def select_header_accept(self, accepts): accepts = [x.lower() for x in accepts] - if 'application/json' in accepts: - return 'application/json' + if "application/json" in accepts: + return "application/json" else: - return ', '.join(accepts) + return ", ".join(accepts) def select_header_content_type(self, content_types): """Returns `Content-Type` based on an array of content_types provided. @@ -474,12 +546,12 @@ def select_header_content_type(self, content_types): :return: Content-Type (e.g. application/json). """ if not content_types: - return 'application/json' + return "application/json" content_types = [x.lower() for x in content_types] - if 'application/json' in content_types or '*/*' in content_types: - return 'application/json' + if "application/json" in content_types or "*/*" in content_types: + return "application/json" else: return content_types[0] @@ -496,12 +568,12 @@ def update_params_for_auth(self, headers, querys, auth_settings): for auth in auth_settings: auth_setting = self.configuration.auth_settings().get(auth) if auth_setting: - if not auth_setting['value']: + if not auth_setting["value"]: continue - elif auth_setting['in'] == 'header': - headers[auth_setting['key']] = auth_setting['value'] - elif auth_setting['in'] == 'query': - querys.append((auth_setting['key'], auth_setting['value'])) + elif auth_setting["in"] == "header": + headers[auth_setting["key"]] = auth_setting["value"] + elif auth_setting["in"] == "query": + querys.append((auth_setting["key"], auth_setting["value"])) elif auth_setting["in"] == "cookie": cookies = headers.get("Cookie", "") cookies = cookies + "; " if cookies else "" @@ -509,7 +581,7 @@ def update_params_for_auth(self, headers, querys, auth_settings): headers["Cookie"] = cookies else: raise ValueError( - 'Authentication token must be in `query`, `cookie` or `header`' + "Authentication token must be in `query`, `cookie` or `header`" ) def __deserialize_file(self, response): @@ -527,8 +599,9 @@ def __deserialize_file(self, response): content_disposition = response.getheader("Content-Disposition") if content_disposition: - filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', - content_disposition).group(1) + filename = re.search( + r'filename=[\'"]?([^\'"\s]+)[\'"]?', content_disposition + ).group(1) path = os.path.join(os.path.dirname(path), filename) with open(path, "wb") as f: @@ -566,13 +639,13 @@ def __deserialize_date(self, string): """ try: from dateutil.parser import parse + return parse(string).date() except ImportError: return string except ValueError: raise rest.ApiException( - status=0, - reason="Failed to parse `{0}` as date object".format(string) + status=0, reason="Failed to parse `{0}` as date object".format(string) ) def __deserialize_datatime(self, string): @@ -585,20 +658,18 @@ def __deserialize_datatime(self, string): """ try: from dateutil.parser import parse + return parse(string) except ImportError: return string except ValueError: raise rest.ApiException( status=0, - reason=( - "Failed to parse `{0}` as datetime object" - .format(string) - ) + reason=("Failed to parse `{0}` as datetime object".format(string)), ) def __hasattr(self, object, name): - return name in object.__class__.__dict__ + return name in object.__class__.__dict__ def __deserialize_model(self, data, klass): """Deserializes list or dict to model. @@ -608,27 +679,33 @@ def __deserialize_model(self, data, klass): :return: model object. """ - if not klass.swagger_types and not self.__hasattr(klass, 'get_real_child_model'): + if not klass.swagger_types and not self.__hasattr( + klass, "get_real_child_model" + ): return data kwargs = {} if klass.swagger_types is not None: for attr, attr_type in six.iteritems(klass.swagger_types): - if (data is not None and - klass.attribute_map[attr] in data and - isinstance(data, (list, dict))): + if ( + data is not None + and klass.attribute_map[attr] in data + and isinstance(data, (list, dict)) + ): value = data[klass.attribute_map[attr]] kwargs[attr] = self.__deserialize(value, attr_type) instance = klass(**kwargs) - if (isinstance(instance, dict) and - klass.swagger_types is not None and - isinstance(data, dict)): + if ( + isinstance(instance, dict) + and klass.swagger_types is not None + and isinstance(data, dict) + ): for key, value in data.items(): if key not in klass.swagger_types: instance[key] = value - if self.__hasattr(instance, 'get_real_child_model'): + if self.__hasattr(instance, "get_real_child_model"): klass_name = instance.get_real_child_model(data) if klass_name: instance = self.__deserialize(data, klass_name) diff --git a/leetcode/configuration.py b/leetcode/configuration.py index 4e6a7a3..e9042d8 100644 --- a/leetcode/configuration.py +++ b/leetcode/configuration.py @@ -16,9 +16,9 @@ import logging import multiprocessing import sys -import urllib3 import six +import urllib3 from six.moves import http_client as httplib @@ -66,7 +66,7 @@ def __init__(self): self.logger["package_logger"] = logging.getLogger("leetcode") self.logger["urllib3_logger"] = logging.getLogger("urllib3") # Log format - self.logger_format = '%(asctime)s %(levelname)s %(message)s' + self.logger_format = "%(asctime)s %(levelname)s %(message)s" # Log stream handler self.logger_stream_handler = None # Log file handler @@ -99,7 +99,7 @@ def __init__(self): # Proxy URL self.proxy = None # Safe chars for path_param - self.safe_chars_for_path_param = '' + self.safe_chars_for_path_param = "" @property def logger_file(self): @@ -220,8 +220,8 @@ def get_basic_auth_token(self): :return: The token for basic HTTP authentication. """ return urllib3.util.make_headers( - basic_auth=self.username + ':' + self.password - ).get('authorization') + basic_auth=self.username + ":" + self.password + ).get("authorization") def auth_settings(self): """Gets Auth Settings dict for api client. @@ -229,34 +229,30 @@ def auth_settings(self): :return: The Auth Settings information dict. """ return { - 'cookieCSRF': - { - 'type': 'api_key', - 'in': 'cookie', - 'key': 'csrftoken', - 'value': self.get_api_key_with_prefix('csrftoken') - }, - 'cookieSession': - { - 'type': 'api_key', - 'in': 'cookie', - 'key': 'LEETCODE_SESSION', - 'value': self.get_api_key_with_prefix('LEETCODE_SESSION') - }, - 'headerCSRF': - { - 'type': 'api_key', - 'in': 'header', - 'key': 'x-csrftoken', - 'value': self.get_api_key_with_prefix('x-csrftoken') - }, - 'referer': - { - 'type': 'api_key', - 'in': 'header', - 'key': 'Referer', - 'value': self.get_api_key_with_prefix('Referer') - }, + "cookieCSRF": { + "type": "api_key", + "in": "cookie", + "key": "csrftoken", + "value": self.get_api_key_with_prefix("csrftoken"), + }, + "cookieSession": { + "type": "api_key", + "in": "cookie", + "key": "LEETCODE_SESSION", + "value": self.get_api_key_with_prefix("LEETCODE_SESSION"), + }, + "headerCSRF": { + "type": "api_key", + "in": "header", + "key": "x-csrftoken", + "value": self.get_api_key_with_prefix("x-csrftoken"), + }, + "referer": { + "type": "api_key", + "in": "header", + "key": "Referer", + "value": self.get_api_key_with_prefix("Referer"), + }, } def to_debug_report(self): @@ -264,9 +260,10 @@ def to_debug_report(self): :return: The report for debugging. """ - return "Python SDK Debug Report:\n"\ - "OS: {env}\n"\ - "Python Version: {pyversion}\n"\ - "Version of the API: 1.0.1-1\n"\ - "SDK Package Version: 1.0.0".\ - format(env=sys.platform, pyversion=sys.version) + return ( + "Python SDK Debug Report:\n" + "OS: {env}\n" + "Python Version: {pyversion}\n" + "Version of the API: 1.0.1-1\n" + "SDK Package Version: 1.0.0".format(env=sys.platform, pyversion=sys.version) + ) diff --git a/leetcode/models/__init__.py b/leetcode/models/__init__.py index 600b91d..a1cd290 100644 --- a/leetcode/models/__init__.py +++ b/leetcode/models/__init__.py @@ -14,7 +14,9 @@ from __future__ import absolute_import # import models into model package -from leetcode.models.any_of_graphql_question_detail_solution import AnyOfGraphqlQuestionDetailSolution +from leetcode.models.any_of_graphql_question_detail_solution import ( + AnyOfGraphqlQuestionDetailSolution, +) from leetcode.models.base_submission_result import BaseSubmissionResult from leetcode.models.difficulty import Difficulty from leetcode.models.graphql_data import GraphqlData diff --git a/leetcode/models/any_of_graphql_question_detail_solution.py b/leetcode/models/any_of_graphql_question_detail_solution.py index 36b4663..656e254 100644 --- a/leetcode/models/any_of_graphql_question_detail_solution.py +++ b/leetcode/models/any_of_graphql_question_detail_solution.py @@ -15,11 +15,13 @@ import six + class AnyOfGraphqlQuestionDetailSolution(object): """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ + """ Attributes: swagger_types (dict): The key is attribute name @@ -27,11 +29,9 @@ class AnyOfGraphqlQuestionDetailSolution(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - swagger_types = { - } + swagger_types = {} - attribute_map = { - } + attribute_map = {} def __init__(self): # noqa: E501 """AnyOfGraphqlQuestionDetailSolution - a model defined in Swagger""" # noqa: E501 @@ -44,18 +44,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.swagger_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value if issubclass(AnyOfGraphqlQuestionDetailSolution, dict): diff --git a/leetcode/models/base_submission_result.py b/leetcode/models/base_submission_result.py index 46c279b..4727fdf 100644 --- a/leetcode/models/base_submission_result.py +++ b/leetcode/models/base_submission_result.py @@ -15,11 +15,13 @@ import six + class BaseSubmissionResult(object): """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ + """ Attributes: swagger_types (dict): The key is attribute name @@ -28,52 +30,74 @@ class BaseSubmissionResult(object): and the value is json key in definition. """ swagger_types = { - 'code_output': 'list[str]', - 'elapsed_time': 'int', - 'full_runtime_error': 'str', - 'lang': 'str', - 'memory': 'int', - 'memory_percentile': 'float', - 'pretty_lang': 'str', - 'run_success': 'bool', - 'runtime_error': 'str', - 'runtime_percentile': 'float', - 'state': 'str', - 'status_code': 'int', - 'status_memory': 'str', - 'status_msg': 'str', - 'status_runtime': 'str', - 'submission_id': 'str', - 'task_finish_time': 'int', - 'total_correct': 'int', - 'total_testcases': 'int', - 'question_id': 'int' + "code_output": "list[str]", + "elapsed_time": "int", + "full_runtime_error": "str", + "lang": "str", + "memory": "int", + "memory_percentile": "float", + "pretty_lang": "str", + "run_success": "bool", + "runtime_error": "str", + "runtime_percentile": "float", + "state": "str", + "status_code": "int", + "status_memory": "str", + "status_msg": "str", + "status_runtime": "str", + "submission_id": "str", + "task_finish_time": "int", + "total_correct": "int", + "total_testcases": "int", + "question_id": "int", } attribute_map = { - 'code_output': 'code_output', - 'elapsed_time': 'elapsed_time', - 'full_runtime_error': 'full_runtime_error', - 'lang': 'lang', - 'memory': 'memory', - 'memory_percentile': 'memory_percentile', - 'pretty_lang': 'pretty_lang', - 'run_success': 'run_success', - 'runtime_error': 'runtime_error', - 'runtime_percentile': 'runtime_percentile', - 'state': 'state', - 'status_code': 'status_code', - 'status_memory': 'status_memory', - 'status_msg': 'status_msg', - 'status_runtime': 'status_runtime', - 'submission_id': 'submission_id', - 'task_finish_time': 'task_finish_time', - 'total_correct': 'total_correct', - 'total_testcases': 'total_testcases', - 'question_id': 'question_id' + "code_output": "code_output", + "elapsed_time": "elapsed_time", + "full_runtime_error": "full_runtime_error", + "lang": "lang", + "memory": "memory", + "memory_percentile": "memory_percentile", + "pretty_lang": "pretty_lang", + "run_success": "run_success", + "runtime_error": "runtime_error", + "runtime_percentile": "runtime_percentile", + "state": "state", + "status_code": "status_code", + "status_memory": "status_memory", + "status_msg": "status_msg", + "status_runtime": "status_runtime", + "submission_id": "submission_id", + "task_finish_time": "task_finish_time", + "total_correct": "total_correct", + "total_testcases": "total_testcases", + "question_id": "question_id", } - def __init__(self, code_output=None, elapsed_time=None, full_runtime_error=None, lang=None, memory=None, memory_percentile=None, pretty_lang=None, run_success=None, runtime_error=None, runtime_percentile=None, state=None, status_code=None, status_memory=None, status_msg=None, status_runtime=None, submission_id=None, task_finish_time=None, total_correct=None, total_testcases=None, question_id=None): # noqa: E501 + def __init__( + self, + code_output=None, + elapsed_time=None, + full_runtime_error=None, + lang=None, + memory=None, + memory_percentile=None, + pretty_lang=None, + run_success=None, + runtime_error=None, + runtime_percentile=None, + state=None, + status_code=None, + status_memory=None, + status_msg=None, + status_runtime=None, + submission_id=None, + task_finish_time=None, + total_correct=None, + total_testcases=None, + question_id=None, + ): # noqa: E501 """BaseSubmissionResult - a model defined in Swagger""" # noqa: E501 self._code_output = None self._elapsed_time = None @@ -166,7 +190,9 @@ def elapsed_time(self, elapsed_time): :type: int """ if elapsed_time is None: - raise ValueError("Invalid value for `elapsed_time`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `elapsed_time`, must not be `None`" + ) # noqa: E501 self._elapsed_time = elapsed_time @@ -210,7 +236,9 @@ def lang(self, lang): :type: str """ if lang is None: - raise ValueError("Invalid value for `lang`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `lang`, must not be `None`" + ) # noqa: E501 self._lang = lang @@ -233,7 +261,9 @@ def memory(self, memory): :type: int """ if memory is None: - raise ValueError("Invalid value for `memory`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `memory`, must not be `None`" + ) # noqa: E501 self._memory = memory @@ -277,7 +307,9 @@ def pretty_lang(self, pretty_lang): :type: str """ if pretty_lang is None: - raise ValueError("Invalid value for `pretty_lang`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `pretty_lang`, must not be `None`" + ) # noqa: E501 self._pretty_lang = pretty_lang @@ -300,7 +332,9 @@ def run_success(self, run_success): :type: bool """ if run_success is None: - raise ValueError("Invalid value for `run_success`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `run_success`, must not be `None`" + ) # noqa: E501 self._run_success = run_success @@ -365,12 +399,15 @@ def state(self, state): :type: str """ if state is None: - raise ValueError("Invalid value for `state`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `state`, must not be `None`" + ) # noqa: E501 allowed_values = ["SUCCESS"] # noqa: E501 if state not in allowed_values: raise ValueError( - "Invalid value for `state` ({0}), must be one of {1}" # noqa: E501 - .format(state, allowed_values) + "Invalid value for `state` ({0}), must be one of {1}".format( # noqa: E501 + state, allowed_values + ) ) self._state = state @@ -394,12 +431,15 @@ def status_code(self, status_code): :type: int """ if status_code is None: - raise ValueError("Invalid value for `status_code`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `status_code`, must not be `None`" + ) # noqa: E501 allowed_values = [10, 11, 15] # noqa: E501 if status_code not in allowed_values: raise ValueError( - "Invalid value for `status_code` ({0}), must be one of {1}" # noqa: E501 - .format(status_code, allowed_values) + "Invalid value for `status_code` ({0}), must be one of {1}".format( # noqa: E501 + status_code, allowed_values + ) ) self._status_code = status_code @@ -444,7 +484,9 @@ def status_msg(self, status_msg): :type: str """ if status_msg is None: - raise ValueError("Invalid value for `status_msg`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `status_msg`, must not be `None`" + ) # noqa: E501 self._status_msg = status_msg @@ -467,7 +509,9 @@ def status_runtime(self, status_runtime): :type: str """ if status_runtime is None: - raise ValueError("Invalid value for `status_runtime`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `status_runtime`, must not be `None`" + ) # noqa: E501 self._status_runtime = status_runtime @@ -490,7 +534,9 @@ def submission_id(self, submission_id): :type: str """ if submission_id is None: - raise ValueError("Invalid value for `submission_id`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `submission_id`, must not be `None`" + ) # noqa: E501 self._submission_id = submission_id @@ -513,7 +559,9 @@ def task_finish_time(self, task_finish_time): :type: int """ if task_finish_time is None: - raise ValueError("Invalid value for `task_finish_time`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `task_finish_time`, must not be `None`" + ) # noqa: E501 self._task_finish_time = task_finish_time @@ -587,18 +635,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.swagger_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value if issubclass(BaseSubmissionResult, dict): diff --git a/leetcode/models/difficulty.py b/leetcode/models/difficulty.py index ce836f6..c9464c8 100644 --- a/leetcode/models/difficulty.py +++ b/leetcode/models/difficulty.py @@ -15,11 +15,13 @@ import six + class Difficulty(object): """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ + """ Attributes: swagger_types (dict): The key is attribute name @@ -27,13 +29,9 @@ class Difficulty(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - swagger_types = { - 'level': 'int' - } + swagger_types = {"level": "int"} - attribute_map = { - 'level': 'level' - } + attribute_map = {"level": "level"} def __init__(self, level=None): # noqa: E501 """Difficulty - a model defined in Swagger""" # noqa: E501 @@ -60,7 +58,9 @@ def level(self, level): :type: int """ if level is None: - raise ValueError("Invalid value for `level`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `level`, must not be `None`" + ) # noqa: E501 self._level = level @@ -71,18 +71,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.swagger_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value if issubclass(Difficulty, dict): diff --git a/leetcode/models/graphql_data.py b/leetcode/models/graphql_data.py index 129915c..5a6b6be 100644 --- a/leetcode/models/graphql_data.py +++ b/leetcode/models/graphql_data.py @@ -15,11 +15,13 @@ import six + class GraphqlData(object): """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ + """ Attributes: swagger_types (dict): The key is attribute name @@ -27,15 +29,9 @@ class GraphqlData(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - swagger_types = { - 'question': 'GraphqlQuestionDetail', - 'user': 'GraphqlUser' - } + swagger_types = {"question": "GraphqlQuestionDetail", "user": "GraphqlUser"} - attribute_map = { - 'question': 'question', - 'user': 'user' - } + attribute_map = {"question": "question", "user": "user"} def __init__(self, question=None, user=None): # noqa: E501 """GraphqlData - a model defined in Swagger""" # noqa: E501 @@ -96,18 +92,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.swagger_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value if issubclass(GraphqlData, dict): diff --git a/leetcode/models/graphql_query.py b/leetcode/models/graphql_query.py index 16c78cf..6d61ac1 100644 --- a/leetcode/models/graphql_query.py +++ b/leetcode/models/graphql_query.py @@ -15,11 +15,13 @@ import six + class GraphqlQuery(object): """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ + """ Attributes: swagger_types (dict): The key is attribute name @@ -28,15 +30,15 @@ class GraphqlQuery(object): and the value is json key in definition. """ swagger_types = { - 'query': 'str', - 'variables': 'GraphqlQueryVariables', - 'operation_name': 'str' + "query": "str", + "variables": "GraphqlQueryVariables", + "operation_name": "str", } attribute_map = { - 'query': 'query', - 'variables': 'variables', - 'operation_name': 'operationName' + "query": "query", + "variables": "variables", + "operation_name": "operationName", } def __init__(self, query=None, variables=None, operation_name=None): # noqa: E501 @@ -69,7 +71,9 @@ def query(self, query): :type: str """ if query is None: - raise ValueError("Invalid value for `query`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `query`, must not be `None`" + ) # noqa: E501 self._query = query @@ -92,7 +96,9 @@ def variables(self, variables): :type: GraphqlQueryVariables """ if variables is None: - raise ValueError("Invalid value for `variables`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `variables`, must not be `None`" + ) # noqa: E501 self._variables = variables @@ -124,18 +130,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.swagger_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value if issubclass(GraphqlQuery, dict): diff --git a/leetcode/models/graphql_query_variables.py b/leetcode/models/graphql_query_variables.py index d9550db..71ebcf5 100644 --- a/leetcode/models/graphql_query_variables.py +++ b/leetcode/models/graphql_query_variables.py @@ -15,11 +15,13 @@ import six + class GraphqlQueryVariables(object): """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ + """ Attributes: swagger_types (dict): The key is attribute name @@ -27,13 +29,9 @@ class GraphqlQueryVariables(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - swagger_types = { - 'title_slug': 'str' - } + swagger_types = {"title_slug": "str"} - attribute_map = { - 'title_slug': 'titleSlug' - } + attribute_map = {"title_slug": "titleSlug"} def __init__(self, title_slug=None): # noqa: E501 """GraphqlQueryVariables - a model defined in Swagger""" # noqa: E501 @@ -70,18 +68,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.swagger_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value if issubclass(GraphqlQueryVariables, dict): diff --git a/leetcode/models/graphql_question_code_snippet.py b/leetcode/models/graphql_question_code_snippet.py index b1d7d66..a7a3b8e 100644 --- a/leetcode/models/graphql_question_code_snippet.py +++ b/leetcode/models/graphql_question_code_snippet.py @@ -15,11 +15,13 @@ import six + class GraphqlQuestionCodeSnippet(object): """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ + """ Attributes: swagger_types (dict): The key is attribute name @@ -28,20 +30,22 @@ class GraphqlQuestionCodeSnippet(object): and the value is json key in definition. """ swagger_types = { - 'lang': 'str', - 'lang_slug': 'str', - 'code': 'str', - 'typename': 'str' + "lang": "str", + "lang_slug": "str", + "code": "str", + "typename": "str", } attribute_map = { - 'lang': 'lang', - 'lang_slug': 'langSlug', - 'code': 'code', - 'typename': '__typename' + "lang": "lang", + "lang_slug": "langSlug", + "code": "code", + "typename": "__typename", } - def __init__(self, lang=None, lang_slug=None, code=None, typename=None): # noqa: E501 + def __init__( + self, lang=None, lang_slug=None, code=None, typename=None + ): # noqa: E501 """GraphqlQuestionCodeSnippet - a model defined in Swagger""" # noqa: E501 self._lang = None self._lang_slug = None @@ -73,7 +77,9 @@ def lang(self, lang): :type: str """ if lang is None: - raise ValueError("Invalid value for `lang`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `lang`, must not be `None`" + ) # noqa: E501 self._lang = lang @@ -96,7 +102,9 @@ def lang_slug(self, lang_slug): :type: str """ if lang_slug is None: - raise ValueError("Invalid value for `lang_slug`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `lang_slug`, must not be `None`" + ) # noqa: E501 self._lang_slug = lang_slug @@ -119,7 +127,9 @@ def code(self, code): :type: str """ if code is None: - raise ValueError("Invalid value for `code`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `code`, must not be `None`" + ) # noqa: E501 self._code = code @@ -151,18 +161,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.swagger_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value if issubclass(GraphqlQuestionCodeSnippet, dict): diff --git a/leetcode/models/graphql_question_contributor.py b/leetcode/models/graphql_question_contributor.py index 0a3f8f6..5f3842a 100644 --- a/leetcode/models/graphql_question_contributor.py +++ b/leetcode/models/graphql_question_contributor.py @@ -15,11 +15,13 @@ import six + class GraphqlQuestionContributor(object): """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ + """ Attributes: swagger_types (dict): The key is attribute name @@ -28,20 +30,22 @@ class GraphqlQuestionContributor(object): and the value is json key in definition. """ swagger_types = { - 'username': 'str', - 'profile_url': 'str', - 'avatar_url': 'str', - 'typename': 'str' + "username": "str", + "profile_url": "str", + "avatar_url": "str", + "typename": "str", } attribute_map = { - 'username': 'username', - 'profile_url': 'profileUrl', - 'avatar_url': 'avatarUrl', - 'typename': '__typename' + "username": "username", + "profile_url": "profileUrl", + "avatar_url": "avatarUrl", + "typename": "__typename", } - def __init__(self, username=None, profile_url=None, avatar_url=None, typename=None): # noqa: E501 + def __init__( + self, username=None, profile_url=None, avatar_url=None, typename=None + ): # noqa: E501 """GraphqlQuestionContributor - a model defined in Swagger""" # noqa: E501 self._username = None self._profile_url = None @@ -73,7 +77,9 @@ def username(self, username): :type: str """ if username is None: - raise ValueError("Invalid value for `username`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `username`, must not be `None`" + ) # noqa: E501 self._username = username @@ -96,7 +102,9 @@ def profile_url(self, profile_url): :type: str """ if profile_url is None: - raise ValueError("Invalid value for `profile_url`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `profile_url`, must not be `None`" + ) # noqa: E501 self._profile_url = profile_url @@ -119,7 +127,9 @@ def avatar_url(self, avatar_url): :type: str """ if avatar_url is None: - raise ValueError("Invalid value for `avatar_url`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `avatar_url`, must not be `None`" + ) # noqa: E501 self._avatar_url = avatar_url @@ -151,18 +161,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.swagger_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value if issubclass(GraphqlQuestionContributor, dict): diff --git a/leetcode/models/graphql_question_detail.py b/leetcode/models/graphql_question_detail.py index b699239..215b67d 100644 --- a/leetcode/models/graphql_question_detail.py +++ b/leetcode/models/graphql_question_detail.py @@ -15,11 +15,13 @@ import six + class GraphqlQuestionDetail(object): """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ + """ Attributes: swagger_types (dict): The key is attribute name @@ -28,86 +30,125 @@ class GraphqlQuestionDetail(object): and the value is json key in definition. """ swagger_types = { - 'question_id': 'str', - 'question_frontend_id': 'str', - 'bound_topic_id': 'str', - 'title': 'str', - 'frequency': 'float', - 'freq_bar': 'float', - 'content': 'str', - 'translated_title': 'str', - 'translated_content': 'str', - 'is_paid_only': 'bool', - 'difficulty': 'str', - 'likes': 'int', - 'dislikes': 'int', - 'is_liked': 'bool', - 'is_favor': 'bool', - 'similar_questions': 'str', - 'contributors': 'list[GraphqlQuestionContributor]', - 'lang_to_valid_playground': 'str', - 'topic_tags': 'list[GraphqlQuestionTopicTag]', - 'company_tag_stats': 'str', - 'code_snippets': 'list[GraphqlQuestionCodeSnippet]', - 'stats': 'str', - 'ac_rate': 'float', - 'hints': 'list[str]', - 'solution': 'AnyOfGraphqlQuestionDetailSolution', - 'has_solution': 'bool', - 'has_video_solution': 'bool', - 'status': 'str', - 'sample_test_case': 'str', - 'judger_available': 'bool', - 'judge_type': 'str', - 'mysql_schemas': 'list[str]', - 'enable_run_code': 'bool', - 'enable_test_mode': 'bool', - 'env_info': 'str', - 'meta_data': 'str', - 'code_definition': 'str' + "question_id": "str", + "question_frontend_id": "str", + "bound_topic_id": "str", + "title": "str", + "frequency": "float", + "freq_bar": "float", + "content": "str", + "translated_title": "str", + "translated_content": "str", + "is_paid_only": "bool", + "difficulty": "str", + "likes": "int", + "dislikes": "int", + "is_liked": "bool", + "is_favor": "bool", + "similar_questions": "str", + "contributors": "list[GraphqlQuestionContributor]", + "lang_to_valid_playground": "str", + "topic_tags": "list[GraphqlQuestionTopicTag]", + "company_tag_stats": "str", + "code_snippets": "list[GraphqlQuestionCodeSnippet]", + "stats": "str", + "ac_rate": "float", + "hints": "list[str]", + "solution": "AnyOfGraphqlQuestionDetailSolution", + "has_solution": "bool", + "has_video_solution": "bool", + "status": "str", + "sample_test_case": "str", + "judger_available": "bool", + "judge_type": "str", + "mysql_schemas": "list[str]", + "enable_run_code": "bool", + "enable_test_mode": "bool", + "env_info": "str", + "meta_data": "str", + "code_definition": "str", } attribute_map = { - 'question_id': 'questionId', - 'question_frontend_id': 'questionFrontendId', - 'bound_topic_id': 'boundTopicId', - 'title': 'title', - 'frequency': 'frequency', - 'freq_bar': 'freqBar', - 'content': 'content', - 'translated_title': 'translatedTitle', - 'translated_content': 'translatedContent', - 'is_paid_only': 'isPaidOnly', - 'difficulty': 'difficulty', - 'likes': 'likes', - 'dislikes': 'dislikes', - 'is_liked': 'isLiked', - 'is_favor': 'isFavor', - 'similar_questions': 'similarQuestions', - 'contributors': 'contributors', - 'lang_to_valid_playground': 'langToValidPlayground', - 'topic_tags': 'topicTags', - 'company_tag_stats': 'companyTagStats', - 'code_snippets': 'codeSnippets', - 'stats': 'stats', - 'ac_rate': 'acRate', - 'hints': 'hints', - 'solution': 'solution', - 'has_solution': 'hasSolution', - 'has_video_solution': 'hasVideoSolution', - 'status': 'status', - 'sample_test_case': 'sampleTestCase', - 'judger_available': 'judgerAvailable', - 'judge_type': 'judgeType', - 'mysql_schemas': 'mysqlSchemas', - 'enable_run_code': 'enableRunCode', - 'enable_test_mode': 'enableTestMode', - 'env_info': 'envInfo', - 'meta_data': 'metaData', - 'code_definition': 'codeDefinition' + "question_id": "questionId", + "question_frontend_id": "questionFrontendId", + "bound_topic_id": "boundTopicId", + "title": "title", + "frequency": "frequency", + "freq_bar": "freqBar", + "content": "content", + "translated_title": "translatedTitle", + "translated_content": "translatedContent", + "is_paid_only": "isPaidOnly", + "difficulty": "difficulty", + "likes": "likes", + "dislikes": "dislikes", + "is_liked": "isLiked", + "is_favor": "isFavor", + "similar_questions": "similarQuestions", + "contributors": "contributors", + "lang_to_valid_playground": "langToValidPlayground", + "topic_tags": "topicTags", + "company_tag_stats": "companyTagStats", + "code_snippets": "codeSnippets", + "stats": "stats", + "ac_rate": "acRate", + "hints": "hints", + "solution": "solution", + "has_solution": "hasSolution", + "has_video_solution": "hasVideoSolution", + "status": "status", + "sample_test_case": "sampleTestCase", + "judger_available": "judgerAvailable", + "judge_type": "judgeType", + "mysql_schemas": "mysqlSchemas", + "enable_run_code": "enableRunCode", + "enable_test_mode": "enableTestMode", + "env_info": "envInfo", + "meta_data": "metaData", + "code_definition": "codeDefinition", } - def __init__(self, question_id=None, question_frontend_id=None, bound_topic_id=None, title=None, frequency=None, freq_bar=None, content=None, translated_title=None, translated_content=None, is_paid_only=None, difficulty=None, likes=None, dislikes=None, is_liked=None, is_favor=None, similar_questions=None, contributors=None, lang_to_valid_playground=None, topic_tags=None, company_tag_stats=None, code_snippets=None, stats=None, ac_rate=None, hints=None, solution=None, has_solution=None, has_video_solution=None, status=None, sample_test_case=None, judger_available=None, judge_type=None, mysql_schemas=None, enable_run_code=None, enable_test_mode=None, env_info=None, meta_data=None, code_definition=None): # noqa: E501 + def __init__( + self, + question_id=None, + question_frontend_id=None, + bound_topic_id=None, + title=None, + frequency=None, + freq_bar=None, + content=None, + translated_title=None, + translated_content=None, + is_paid_only=None, + difficulty=None, + likes=None, + dislikes=None, + is_liked=None, + is_favor=None, + similar_questions=None, + contributors=None, + lang_to_valid_playground=None, + topic_tags=None, + company_tag_stats=None, + code_snippets=None, + stats=None, + ac_rate=None, + hints=None, + solution=None, + has_solution=None, + has_video_solution=None, + status=None, + sample_test_case=None, + judger_available=None, + judge_type=None, + mysql_schemas=None, + enable_run_code=None, + enable_test_mode=None, + env_info=None, + meta_data=None, + code_definition=None, + ): # noqa: E501 """GraphqlQuestionDetail - a model defined in Swagger""" # noqa: E501 self._question_id = None self._question_frontend_id = None @@ -1006,18 +1047,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.swagger_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value if issubclass(GraphqlQuestionDetail, dict): diff --git a/leetcode/models/graphql_question_solution.py b/leetcode/models/graphql_question_solution.py index eae0c04..b3d122b 100644 --- a/leetcode/models/graphql_question_solution.py +++ b/leetcode/models/graphql_question_solution.py @@ -15,11 +15,13 @@ import six + class GraphqlQuestionSolution(object): """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ + """ Attributes: swagger_types (dict): The key is attribute name @@ -27,16 +29,12 @@ class GraphqlQuestionSolution(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - swagger_types = { - 'id': 'str', - 'can_see_detail': 'bool', - 'typename': 'str' - } + swagger_types = {"id": "str", "can_see_detail": "bool", "typename": "str"} attribute_map = { - 'id': 'id', - 'can_see_detail': 'canSeeDetail', - 'typename': '__typename' + "id": "id", + "can_see_detail": "canSeeDetail", + "typename": "__typename", } def __init__(self, id=None, can_see_detail=None, typename=None): # noqa: E501 @@ -91,7 +89,9 @@ def can_see_detail(self, can_see_detail): :type: bool """ if can_see_detail is None: - raise ValueError("Invalid value for `can_see_detail`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `can_see_detail`, must not be `None`" + ) # noqa: E501 self._can_see_detail = can_see_detail @@ -114,7 +114,9 @@ def typename(self, typename): :type: str """ if typename is None: - raise ValueError("Invalid value for `typename`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `typename`, must not be `None`" + ) # noqa: E501 self._typename = typename @@ -125,18 +127,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.swagger_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value if issubclass(GraphqlQuestionSolution, dict): diff --git a/leetcode/models/graphql_question_topic_tag.py b/leetcode/models/graphql_question_topic_tag.py index 82bef0c..15c9934 100644 --- a/leetcode/models/graphql_question_topic_tag.py +++ b/leetcode/models/graphql_question_topic_tag.py @@ -15,11 +15,13 @@ import six + class GraphqlQuestionTopicTag(object): """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ + """ Attributes: swagger_types (dict): The key is attribute name @@ -28,20 +30,22 @@ class GraphqlQuestionTopicTag(object): and the value is json key in definition. """ swagger_types = { - 'name': 'str', - 'slug': 'str', - 'translated_name': 'str', - 'typename': 'str' + "name": "str", + "slug": "str", + "translated_name": "str", + "typename": "str", } attribute_map = { - 'name': 'name', - 'slug': 'slug', - 'translated_name': 'translatedName', - 'typename': '__typename' + "name": "name", + "slug": "slug", + "translated_name": "translatedName", + "typename": "__typename", } - def __init__(self, name=None, slug=None, translated_name=None, typename=None): # noqa: E501 + def __init__( + self, name=None, slug=None, translated_name=None, typename=None + ): # noqa: E501 """GraphqlQuestionTopicTag - a model defined in Swagger""" # noqa: E501 self._name = None self._slug = None @@ -74,7 +78,9 @@ def name(self, name): :type: str """ if name is None: - raise ValueError("Invalid value for `name`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `name`, must not be `None`" + ) # noqa: E501 self._name = name @@ -97,7 +103,9 @@ def slug(self, slug): :type: str """ if slug is None: - raise ValueError("Invalid value for `slug`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `slug`, must not be `None`" + ) # noqa: E501 self._slug = slug @@ -150,18 +158,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.swagger_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value if issubclass(GraphqlQuestionTopicTag, dict): diff --git a/leetcode/models/graphql_response.py b/leetcode/models/graphql_response.py index 9cc42a0..0fa94a3 100644 --- a/leetcode/models/graphql_response.py +++ b/leetcode/models/graphql_response.py @@ -15,11 +15,13 @@ import six + class GraphqlResponse(object): """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ + """ Attributes: swagger_types (dict): The key is attribute name @@ -27,13 +29,9 @@ class GraphqlResponse(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - swagger_types = { - 'data': 'GraphqlData' - } + swagger_types = {"data": "GraphqlData"} - attribute_map = { - 'data': 'data' - } + attribute_map = {"data": "data"} def __init__(self, data=None): # noqa: E501 """GraphqlResponse - a model defined in Swagger""" # noqa: E501 @@ -60,7 +58,9 @@ def data(self, data): :type: GraphqlData """ if data is None: - raise ValueError("Invalid value for `data`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `data`, must not be `None`" + ) # noqa: E501 self._data = data @@ -71,18 +71,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.swagger_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value if issubclass(GraphqlResponse, dict): diff --git a/leetcode/models/graphql_user.py b/leetcode/models/graphql_user.py index d2b7ec8..4f3d1fd 100644 --- a/leetcode/models/graphql_user.py +++ b/leetcode/models/graphql_user.py @@ -15,11 +15,13 @@ import six + class GraphqlUser(object): """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ + """ Attributes: swagger_types (dict): The key is attribute name @@ -27,14 +29,11 @@ class GraphqlUser(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - swagger_types = { - 'username': 'str', - 'is_current_user_premium': 'bool' - } + swagger_types = {"username": "str", "is_current_user_premium": "bool"} attribute_map = { - 'username': 'username', - 'is_current_user_premium': 'isCurrentUserPremium' + "username": "username", + "is_current_user_premium": "isCurrentUserPremium", } def __init__(self, username=None, is_current_user_premium=None): # noqa: E501 @@ -96,18 +95,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.swagger_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value if issubclass(GraphqlUser, dict): diff --git a/leetcode/models/id.py b/leetcode/models/id.py index 1cb7392..053f977 100644 --- a/leetcode/models/id.py +++ b/leetcode/models/id.py @@ -15,11 +15,13 @@ import six + class Id(object): """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ + """ Attributes: swagger_types (dict): The key is attribute name @@ -27,11 +29,9 @@ class Id(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - swagger_types = { - } + swagger_types = {} - attribute_map = { - } + attribute_map = {} def __init__(self): # noqa: E501 """Id - a model defined in Swagger""" # noqa: E501 @@ -44,18 +44,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.swagger_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value if issubclass(Id, dict): diff --git a/leetcode/models/inline_response200.py b/leetcode/models/inline_response200.py index b00c473..dc0a072 100644 --- a/leetcode/models/inline_response200.py +++ b/leetcode/models/inline_response200.py @@ -15,11 +15,13 @@ import six + class InlineResponse200(object): """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ + """ Attributes: swagger_types (dict): The key is attribute name @@ -27,11 +29,9 @@ class InlineResponse200(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - swagger_types = { - } + swagger_types = {} - attribute_map = { - } + attribute_map = {} def __init__(self): # noqa: E501 """InlineResponse200 - a model defined in Swagger""" # noqa: E501 @@ -44,18 +44,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.swagger_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value if issubclass(InlineResponse200, dict): diff --git a/leetcode/models/interpretation.py b/leetcode/models/interpretation.py index 80ce489..6b5ef2d 100644 --- a/leetcode/models/interpretation.py +++ b/leetcode/models/interpretation.py @@ -15,11 +15,13 @@ import six + class Interpretation(object): """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ + """ Attributes: swagger_types (dict): The key is attribute name @@ -27,15 +29,9 @@ class Interpretation(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - swagger_types = { - 'interpret_id': 'str', - 'test_case': 'str' - } + swagger_types = {"interpret_id": "str", "test_case": "str"} - attribute_map = { - 'interpret_id': 'interpret_id', - 'test_case': 'test_case' - } + attribute_map = {"interpret_id": "interpret_id", "test_case": "test_case"} def __init__(self, interpret_id=None, test_case=None): # noqa: E501 """Interpretation - a model defined in Swagger""" # noqa: E501 @@ -64,7 +60,9 @@ def interpret_id(self, interpret_id): :type: str """ if interpret_id is None: - raise ValueError("Invalid value for `interpret_id`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `interpret_id`, must not be `None`" + ) # noqa: E501 self._interpret_id = interpret_id @@ -87,7 +85,9 @@ def test_case(self, test_case): :type: str """ if test_case is None: - raise ValueError("Invalid value for `test_case`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `test_case`, must not be `None`" + ) # noqa: E501 self._test_case = test_case @@ -98,18 +98,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.swagger_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value if issubclass(Interpretation, dict): diff --git a/leetcode/models/one_ofid.py b/leetcode/models/one_ofid.py index a1d002b..99e024c 100644 --- a/leetcode/models/one_ofid.py +++ b/leetcode/models/one_ofid.py @@ -15,11 +15,13 @@ import six + class OneOfid(object): """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ + """ Attributes: swagger_types (dict): The key is attribute name @@ -27,11 +29,9 @@ class OneOfid(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - swagger_types = { - } + swagger_types = {} - attribute_map = { - } + attribute_map = {} def __init__(self): # noqa: E501 """OneOfid - a model defined in Swagger""" # noqa: E501 @@ -44,18 +44,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.swagger_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value if issubclass(OneOfid, dict): diff --git a/leetcode/models/one_ofinline_response200.py b/leetcode/models/one_ofinline_response200.py index c0765b4..c65680f 100644 --- a/leetcode/models/one_ofinline_response200.py +++ b/leetcode/models/one_ofinline_response200.py @@ -15,11 +15,13 @@ import six + class OneOfinlineResponse200(object): """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ + """ Attributes: swagger_types (dict): The key is attribute name @@ -27,11 +29,9 @@ class OneOfinlineResponse200(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - swagger_types = { - } + swagger_types = {} - attribute_map = { - } + attribute_map = {} def __init__(self): # noqa: E501 """OneOfinlineResponse200 - a model defined in Swagger""" # noqa: E501 @@ -44,18 +44,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.swagger_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value if issubclass(OneOfinlineResponse200, dict): diff --git a/leetcode/models/problems.py b/leetcode/models/problems.py index 9b76f7b..6095d43 100644 --- a/leetcode/models/problems.py +++ b/leetcode/models/problems.py @@ -15,11 +15,13 @@ import six + class Problems(object): """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ + """ Attributes: swagger_types (dict): The key is attribute name @@ -28,32 +30,44 @@ class Problems(object): and the value is json key in definition. """ swagger_types = { - 'user_name': 'str', - 'num_solved': 'int', - 'num_total': 'int', - 'ac_easy': 'int', - 'ac_medium': 'int', - 'ac_hard': 'int', - 'stat_status_pairs': 'list[StatStatusPair]', - 'frequency_high': 'int', - 'frequency_mid': 'int', - 'category_slug': 'str' + "user_name": "str", + "num_solved": "int", + "num_total": "int", + "ac_easy": "int", + "ac_medium": "int", + "ac_hard": "int", + "stat_status_pairs": "list[StatStatusPair]", + "frequency_high": "int", + "frequency_mid": "int", + "category_slug": "str", } attribute_map = { - 'user_name': 'user_name', - 'num_solved': 'num_solved', - 'num_total': 'num_total', - 'ac_easy': 'ac_easy', - 'ac_medium': 'ac_medium', - 'ac_hard': 'ac_hard', - 'stat_status_pairs': 'stat_status_pairs', - 'frequency_high': 'frequency_high', - 'frequency_mid': 'frequency_mid', - 'category_slug': 'category_slug' + "user_name": "user_name", + "num_solved": "num_solved", + "num_total": "num_total", + "ac_easy": "ac_easy", + "ac_medium": "ac_medium", + "ac_hard": "ac_hard", + "stat_status_pairs": "stat_status_pairs", + "frequency_high": "frequency_high", + "frequency_mid": "frequency_mid", + "category_slug": "category_slug", } - def __init__(self, user_name=None, num_solved=None, num_total=None, ac_easy=None, ac_medium=None, ac_hard=None, stat_status_pairs=None, frequency_high=None, frequency_mid=None, category_slug=None): # noqa: E501 + def __init__( + self, + user_name=None, + num_solved=None, + num_total=None, + ac_easy=None, + ac_medium=None, + ac_hard=None, + stat_status_pairs=None, + frequency_high=None, + frequency_mid=None, + category_slug=None, + ): # noqa: E501 """Problems - a model defined in Swagger""" # noqa: E501 self._user_name = None self._num_solved = None @@ -96,7 +110,9 @@ def user_name(self, user_name): :type: str """ if user_name is None: - raise ValueError("Invalid value for `user_name`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `user_name`, must not be `None`" + ) # noqa: E501 self._user_name = user_name @@ -119,7 +135,9 @@ def num_solved(self, num_solved): :type: int """ if num_solved is None: - raise ValueError("Invalid value for `num_solved`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `num_solved`, must not be `None`" + ) # noqa: E501 self._num_solved = num_solved @@ -142,7 +160,9 @@ def num_total(self, num_total): :type: int """ if num_total is None: - raise ValueError("Invalid value for `num_total`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `num_total`, must not be `None`" + ) # noqa: E501 self._num_total = num_total @@ -165,7 +185,9 @@ def ac_easy(self, ac_easy): :type: int """ if ac_easy is None: - raise ValueError("Invalid value for `ac_easy`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `ac_easy`, must not be `None`" + ) # noqa: E501 self._ac_easy = ac_easy @@ -188,7 +210,9 @@ def ac_medium(self, ac_medium): :type: int """ if ac_medium is None: - raise ValueError("Invalid value for `ac_medium`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `ac_medium`, must not be `None`" + ) # noqa: E501 self._ac_medium = ac_medium @@ -211,7 +235,9 @@ def ac_hard(self, ac_hard): :type: int """ if ac_hard is None: - raise ValueError("Invalid value for `ac_hard`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `ac_hard`, must not be `None`" + ) # noqa: E501 self._ac_hard = ac_hard @@ -234,7 +260,9 @@ def stat_status_pairs(self, stat_status_pairs): :type: list[StatStatusPair] """ if stat_status_pairs is None: - raise ValueError("Invalid value for `stat_status_pairs`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `stat_status_pairs`, must not be `None`" + ) # noqa: E501 self._stat_status_pairs = stat_status_pairs @@ -257,7 +285,9 @@ def frequency_high(self, frequency_high): :type: int """ if frequency_high is None: - raise ValueError("Invalid value for `frequency_high`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `frequency_high`, must not be `None`" + ) # noqa: E501 self._frequency_high = frequency_high @@ -280,7 +310,9 @@ def frequency_mid(self, frequency_mid): :type: int """ if frequency_mid is None: - raise ValueError("Invalid value for `frequency_mid`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `frequency_mid`, must not be `None`" + ) # noqa: E501 self._frequency_mid = frequency_mid @@ -303,7 +335,9 @@ def category_slug(self, category_slug): :type: str """ if category_slug is None: - raise ValueError("Invalid value for `category_slug`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `category_slug`, must not be `None`" + ) # noqa: E501 self._category_slug = category_slug @@ -314,18 +348,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.swagger_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value if issubclass(Problems, dict): diff --git a/leetcode/models/stat.py b/leetcode/models/stat.py index 887e7f1..5d76fe8 100644 --- a/leetcode/models/stat.py +++ b/leetcode/models/stat.py @@ -15,11 +15,13 @@ import six + class Stat(object): """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ + """ Attributes: swagger_types (dict): The key is attribute name @@ -28,34 +30,47 @@ class Stat(object): and the value is json key in definition. """ swagger_types = { - 'question_id': 'int', - 'question__article__live': 'bool', - 'question__article__slug': 'str', - 'question__article__has_video_solution': 'bool', - 'question__title': 'str', - 'question__title_slug': 'str', - 'question__hide': 'bool', - 'total_acs': 'int', - 'total_submitted': 'int', - 'frontend_question_id': 'int', - 'is_new_question': 'bool' + "question_id": "int", + "question__article__live": "bool", + "question__article__slug": "str", + "question__article__has_video_solution": "bool", + "question__title": "str", + "question__title_slug": "str", + "question__hide": "bool", + "total_acs": "int", + "total_submitted": "int", + "frontend_question_id": "int", + "is_new_question": "bool", } attribute_map = { - 'question_id': 'question_id', - 'question__article__live': 'question__article__live', - 'question__article__slug': 'question__article__slug', - 'question__article__has_video_solution': 'question__article__has_video_solution', - 'question__title': 'question__title', - 'question__title_slug': 'question__title_slug', - 'question__hide': 'question__hide', - 'total_acs': 'total_acs', - 'total_submitted': 'total_submitted', - 'frontend_question_id': 'frontend_question_id', - 'is_new_question': 'is_new_question' + "question_id": "question_id", + "question__article__live": "question__article__live", + "question__article__slug": "question__article__slug", + "question__article__has_video_solution": "question__article__has_video_solution", + "question__title": "question__title", + "question__title_slug": "question__title_slug", + "question__hide": "question__hide", + "total_acs": "total_acs", + "total_submitted": "total_submitted", + "frontend_question_id": "frontend_question_id", + "is_new_question": "is_new_question", } - def __init__(self, question_id=None, question__article__live=None, question__article__slug=None, question__article__has_video_solution=None, question__title=None, question__title_slug=None, question__hide=None, total_acs=None, total_submitted=None, frontend_question_id=None, is_new_question=None): # noqa: E501 + def __init__( + self, + question_id=None, + question__article__live=None, + question__article__slug=None, + question__article__has_video_solution=None, + question__title=None, + question__title_slug=None, + question__hide=None, + total_acs=None, + total_submitted=None, + frontend_question_id=None, + is_new_question=None, + ): # noqa: E501 """Stat - a model defined in Swagger""" # noqa: E501 self._question_id = None self._question__article__live = None @@ -75,7 +90,9 @@ def __init__(self, question_id=None, question__article__live=None, question__art if question__article__slug is not None: self.question__article__slug = question__article__slug if question__article__has_video_solution is not None: - self.question__article__has_video_solution = question__article__has_video_solution + self.question__article__has_video_solution = ( + question__article__has_video_solution + ) self.question__title = question__title self.question__title_slug = question__title_slug self.question__hide = question__hide @@ -103,7 +120,9 @@ def question_id(self, question_id): :type: int """ if question_id is None: - raise ValueError("Invalid value for `question_id`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `question_id`, must not be `None`" + ) # noqa: E501 self._question_id = question_id @@ -160,7 +179,9 @@ def question__article__has_video_solution(self): return self._question__article__has_video_solution @question__article__has_video_solution.setter - def question__article__has_video_solution(self, question__article__has_video_solution): + def question__article__has_video_solution( + self, question__article__has_video_solution + ): """Sets the question__article__has_video_solution of this Stat. @@ -168,7 +189,9 @@ def question__article__has_video_solution(self, question__article__has_video_sol :type: bool """ - self._question__article__has_video_solution = question__article__has_video_solution + self._question__article__has_video_solution = ( + question__article__has_video_solution + ) @property def question__title(self): @@ -189,7 +212,9 @@ def question__title(self, question__title): :type: str """ if question__title is None: - raise ValueError("Invalid value for `question__title`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `question__title`, must not be `None`" + ) # noqa: E501 self._question__title = question__title @@ -212,7 +237,9 @@ def question__title_slug(self, question__title_slug): :type: str """ if question__title_slug is None: - raise ValueError("Invalid value for `question__title_slug`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `question__title_slug`, must not be `None`" + ) # noqa: E501 self._question__title_slug = question__title_slug @@ -235,7 +262,9 @@ def question__hide(self, question__hide): :type: bool """ if question__hide is None: - raise ValueError("Invalid value for `question__hide`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `question__hide`, must not be `None`" + ) # noqa: E501 self._question__hide = question__hide @@ -258,7 +287,9 @@ def total_acs(self, total_acs): :type: int """ if total_acs is None: - raise ValueError("Invalid value for `total_acs`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `total_acs`, must not be `None`" + ) # noqa: E501 self._total_acs = total_acs @@ -281,7 +312,9 @@ def total_submitted(self, total_submitted): :type: int """ if total_submitted is None: - raise ValueError("Invalid value for `total_submitted`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `total_submitted`, must not be `None`" + ) # noqa: E501 self._total_submitted = total_submitted @@ -304,7 +337,9 @@ def frontend_question_id(self, frontend_question_id): :type: int """ if frontend_question_id is None: - raise ValueError("Invalid value for `frontend_question_id`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `frontend_question_id`, must not be `None`" + ) # noqa: E501 self._frontend_question_id = frontend_question_id @@ -327,7 +362,9 @@ def is_new_question(self, is_new_question): :type: bool """ if is_new_question is None: - raise ValueError("Invalid value for `is_new_question`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `is_new_question`, must not be `None`" + ) # noqa: E501 self._is_new_question = is_new_question @@ -338,18 +375,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.swagger_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value if issubclass(Stat, dict): diff --git a/leetcode/models/stat_status_pair.py b/leetcode/models/stat_status_pair.py index e8493c8..b82c8c7 100644 --- a/leetcode/models/stat_status_pair.py +++ b/leetcode/models/stat_status_pair.py @@ -15,11 +15,13 @@ import six + class StatStatusPair(object): """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ + """ Attributes: swagger_types (dict): The key is attribute name @@ -28,26 +30,35 @@ class StatStatusPair(object): and the value is json key in definition. """ swagger_types = { - 'stat': 'Stat', - 'status': 'str', - 'difficulty': 'Difficulty', - 'paid_only': 'bool', - 'is_favor': 'bool', - 'frequency': 'float', - 'progress': 'float' + "stat": "Stat", + "status": "str", + "difficulty": "Difficulty", + "paid_only": "bool", + "is_favor": "bool", + "frequency": "float", + "progress": "float", } attribute_map = { - 'stat': 'stat', - 'status': 'status', - 'difficulty': 'difficulty', - 'paid_only': 'paid_only', - 'is_favor': 'is_favor', - 'frequency': 'frequency', - 'progress': 'progress' + "stat": "stat", + "status": "status", + "difficulty": "difficulty", + "paid_only": "paid_only", + "is_favor": "is_favor", + "frequency": "frequency", + "progress": "progress", } - def __init__(self, stat=None, status=None, difficulty=None, paid_only=None, is_favor=None, frequency=None, progress=None): # noqa: E501 + def __init__( + self, + stat=None, + status=None, + difficulty=None, + paid_only=None, + is_favor=None, + frequency=None, + progress=None, + ): # noqa: E501 """StatStatusPair - a model defined in Swagger""" # noqa: E501 self._stat = None self._status = None @@ -85,7 +96,9 @@ def stat(self, stat): :type: Stat """ if stat is None: - raise ValueError("Invalid value for `stat`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `stat`, must not be `None`" + ) # noqa: E501 self._stat = stat @@ -129,7 +142,9 @@ def difficulty(self, difficulty): :type: Difficulty """ if difficulty is None: - raise ValueError("Invalid value for `difficulty`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `difficulty`, must not be `None`" + ) # noqa: E501 self._difficulty = difficulty @@ -152,7 +167,9 @@ def paid_only(self, paid_only): :type: bool """ if paid_only is None: - raise ValueError("Invalid value for `paid_only`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `paid_only`, must not be `None`" + ) # noqa: E501 self._paid_only = paid_only @@ -175,7 +192,9 @@ def is_favor(self, is_favor): :type: bool """ if is_favor is None: - raise ValueError("Invalid value for `is_favor`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `is_favor`, must not be `None`" + ) # noqa: E501 self._is_favor = is_favor @@ -198,7 +217,9 @@ def frequency(self, frequency): :type: float """ if frequency is None: - raise ValueError("Invalid value for `frequency`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `frequency`, must not be `None`" + ) # noqa: E501 self._frequency = frequency @@ -221,7 +242,9 @@ def progress(self, progress): :type: float """ if progress is None: - raise ValueError("Invalid value for `progress`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `progress`, must not be `None`" + ) # noqa: E501 self._progress = progress @@ -232,18 +255,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.swagger_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value if issubclass(StatStatusPair, dict): diff --git a/leetcode/models/submission.py b/leetcode/models/submission.py index cfd20a2..0e8c0e6 100644 --- a/leetcode/models/submission.py +++ b/leetcode/models/submission.py @@ -15,11 +15,13 @@ import six + class Submission(object): """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ + """ Attributes: swagger_types (dict): The key is attribute name @@ -28,22 +30,29 @@ class Submission(object): and the value is json key in definition. """ swagger_types = { - 'judge_type': 'str', - 'lang': 'str', - 'question_id': 'int', - 'test_mode': 'bool', - 'typed_code': 'str' + "judge_type": "str", + "lang": "str", + "question_id": "int", + "test_mode": "bool", + "typed_code": "str", } attribute_map = { - 'judge_type': 'judge_type', - 'lang': 'lang', - 'question_id': 'question_id', - 'test_mode': 'test_mode', - 'typed_code': 'typed_code' + "judge_type": "judge_type", + "lang": "lang", + "question_id": "question_id", + "test_mode": "test_mode", + "typed_code": "typed_code", } - def __init__(self, judge_type=None, lang=None, question_id=None, test_mode=None, typed_code=None): # noqa: E501 + def __init__( + self, + judge_type=None, + lang=None, + question_id=None, + test_mode=None, + typed_code=None, + ): # noqa: E501 """Submission - a model defined in Swagger""" # noqa: E501 self._judge_type = None self._lang = None @@ -76,12 +85,15 @@ def judge_type(self, judge_type): :type: str """ if judge_type is None: - raise ValueError("Invalid value for `judge_type`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `judge_type`, must not be `None`" + ) # noqa: E501 allowed_values = ["large"] # noqa: E501 if judge_type not in allowed_values: raise ValueError( - "Invalid value for `judge_type` ({0}), must be one of {1}" # noqa: E501 - .format(judge_type, allowed_values) + "Invalid value for `judge_type` ({0}), must be one of {1}".format( # noqa: E501 + judge_type, allowed_values + ) ) self._judge_type = judge_type @@ -105,7 +117,9 @@ def lang(self, lang): :type: str """ if lang is None: - raise ValueError("Invalid value for `lang`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `lang`, must not be `None`" + ) # noqa: E501 self._lang = lang @@ -128,7 +142,9 @@ def question_id(self, question_id): :type: int """ if question_id is None: - raise ValueError("Invalid value for `question_id`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `question_id`, must not be `None`" + ) # noqa: E501 self._question_id = question_id @@ -151,7 +167,9 @@ def test_mode(self, test_mode): :type: bool """ if test_mode is None: - raise ValueError("Invalid value for `test_mode`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `test_mode`, must not be `None`" + ) # noqa: E501 self._test_mode = test_mode @@ -174,7 +192,9 @@ def typed_code(self, typed_code): :type: str """ if typed_code is None: - raise ValueError("Invalid value for `typed_code`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `typed_code`, must not be `None`" + ) # noqa: E501 self._typed_code = typed_code @@ -185,18 +205,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.swagger_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value if issubclass(Submission, dict): diff --git a/leetcode/models/submission_id.py b/leetcode/models/submission_id.py index b634f90..dbb3583 100644 --- a/leetcode/models/submission_id.py +++ b/leetcode/models/submission_id.py @@ -15,11 +15,13 @@ import six + class SubmissionId(object): """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ + """ Attributes: swagger_types (dict): The key is attribute name @@ -27,13 +29,9 @@ class SubmissionId(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - swagger_types = { - 'submission_id': 'int' - } + swagger_types = {"submission_id": "int"} - attribute_map = { - 'submission_id': 'submission_id' - } + attribute_map = {"submission_id": "submission_id"} def __init__(self, submission_id=None): # noqa: E501 """SubmissionId - a model defined in Swagger""" # noqa: E501 @@ -60,7 +58,9 @@ def submission_id(self, submission_id): :type: int """ if submission_id is None: - raise ValueError("Invalid value for `submission_id`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `submission_id`, must not be `None`" + ) # noqa: E501 self._submission_id = submission_id @@ -71,18 +71,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.swagger_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value if issubclass(SubmissionId, dict): diff --git a/leetcode/models/submission_result.py b/leetcode/models/submission_result.py index 236ee57..bab2f7f 100644 --- a/leetcode/models/submission_result.py +++ b/leetcode/models/submission_result.py @@ -14,13 +14,18 @@ import re # noqa: F401 import six -from leetcode.models.base_submission_result import BaseSubmissionResult # noqa: F401,E501 + +from leetcode.models.base_submission_result import ( # noqa: F401,E501 + BaseSubmissionResult, +) + class SubmissionResult(BaseSubmissionResult): """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ + """ Attributes: swagger_types (dict): The key is attribute name @@ -29,28 +34,38 @@ class SubmissionResult(BaseSubmissionResult): and the value is json key in definition. """ swagger_types = { - 'compare_result': 'str', - 'std_output': 'str', - 'last_testcase': 'str', - 'expected_output': 'str', - 'input_formatted': 'str', - 'input': 'str' + "compare_result": "str", + "std_output": "str", + "last_testcase": "str", + "expected_output": "str", + "input_formatted": "str", + "input": "str", } if hasattr(BaseSubmissionResult, "swagger_types"): swagger_types.update(BaseSubmissionResult.swagger_types) attribute_map = { - 'compare_result': 'compare_result', - 'std_output': 'std_output', - 'last_testcase': 'last_testcase', - 'expected_output': 'expected_output', - 'input_formatted': 'input_formatted', - 'input': 'input' + "compare_result": "compare_result", + "std_output": "std_output", + "last_testcase": "last_testcase", + "expected_output": "expected_output", + "input_formatted": "input_formatted", + "input": "input", } if hasattr(BaseSubmissionResult, "attribute_map"): attribute_map.update(BaseSubmissionResult.attribute_map) - def __init__(self, compare_result=None, std_output=None, last_testcase=None, expected_output=None, input_formatted=None, input=None, *args, **kwargs): # noqa: E501 + def __init__( + self, + compare_result=None, + std_output=None, + last_testcase=None, + expected_output=None, + input_formatted=None, + input=None, + *args, + **kwargs + ): # noqa: E501 """SubmissionResult - a model defined in Swagger""" # noqa: E501 self._compare_result = None self._std_output = None @@ -86,7 +101,9 @@ def compare_result(self, compare_result): :type: str """ if compare_result is None: - raise ValueError("Invalid value for `compare_result`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `compare_result`, must not be `None`" + ) # noqa: E501 self._compare_result = compare_result @@ -109,7 +126,9 @@ def std_output(self, std_output): :type: str """ if std_output is None: - raise ValueError("Invalid value for `std_output`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `std_output`, must not be `None`" + ) # noqa: E501 self._std_output = std_output @@ -132,7 +151,9 @@ def last_testcase(self, last_testcase): :type: str """ if last_testcase is None: - raise ValueError("Invalid value for `last_testcase`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `last_testcase`, must not be `None`" + ) # noqa: E501 self._last_testcase = last_testcase @@ -155,7 +176,9 @@ def expected_output(self, expected_output): :type: str """ if expected_output is None: - raise ValueError("Invalid value for `expected_output`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `expected_output`, must not be `None`" + ) # noqa: E501 self._expected_output = expected_output @@ -178,7 +201,9 @@ def input_formatted(self, input_formatted): :type: str """ if input_formatted is None: - raise ValueError("Invalid value for `input_formatted`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `input_formatted`, must not be `None`" + ) # noqa: E501 self._input_formatted = input_formatted @@ -201,7 +226,9 @@ def input(self, input): :type: str """ if input is None: - raise ValueError("Invalid value for `input`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `input`, must not be `None`" + ) # noqa: E501 self._input = input @@ -212,18 +239,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.swagger_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value if issubclass(SubmissionResult, dict): diff --git a/leetcode/models/test_submission.py b/leetcode/models/test_submission.py index 49390a6..d84eec9 100644 --- a/leetcode/models/test_submission.py +++ b/leetcode/models/test_submission.py @@ -15,11 +15,13 @@ import six + class TestSubmission(object): """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ + """ Attributes: swagger_types (dict): The key is attribute name @@ -28,22 +30,29 @@ class TestSubmission(object): and the value is json key in definition. """ swagger_types = { - 'data_input': 'str', - 'lang': 'str', - 'question_id': 'int', - 'test_mode': 'bool', - 'typed_code': 'str' + "data_input": "str", + "lang": "str", + "question_id": "int", + "test_mode": "bool", + "typed_code": "str", } attribute_map = { - 'data_input': 'data_input', - 'lang': 'lang', - 'question_id': 'question_id', - 'test_mode': 'test_mode', - 'typed_code': 'typed_code' + "data_input": "data_input", + "lang": "lang", + "question_id": "question_id", + "test_mode": "test_mode", + "typed_code": "typed_code", } - def __init__(self, data_input=None, lang=None, question_id=None, test_mode=None, typed_code=None): # noqa: E501 + def __init__( + self, + data_input=None, + lang=None, + question_id=None, + test_mode=None, + typed_code=None, + ): # noqa: E501 """TestSubmission - a model defined in Swagger""" # noqa: E501 self._data_input = None self._lang = None @@ -76,7 +85,9 @@ def data_input(self, data_input): :type: str """ if data_input is None: - raise ValueError("Invalid value for `data_input`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `data_input`, must not be `None`" + ) # noqa: E501 self._data_input = data_input @@ -99,7 +110,9 @@ def lang(self, lang): :type: str """ if lang is None: - raise ValueError("Invalid value for `lang`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `lang`, must not be `None`" + ) # noqa: E501 self._lang = lang @@ -122,7 +135,9 @@ def question_id(self, question_id): :type: int """ if question_id is None: - raise ValueError("Invalid value for `question_id`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `question_id`, must not be `None`" + ) # noqa: E501 self._question_id = question_id @@ -145,7 +160,9 @@ def test_mode(self, test_mode): :type: bool """ if test_mode is None: - raise ValueError("Invalid value for `test_mode`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `test_mode`, must not be `None`" + ) # noqa: E501 self._test_mode = test_mode @@ -168,7 +185,9 @@ def typed_code(self, typed_code): :type: str """ if typed_code is None: - raise ValueError("Invalid value for `typed_code`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `typed_code`, must not be `None`" + ) # noqa: E501 self._typed_code = typed_code @@ -179,18 +198,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.swagger_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value if issubclass(TestSubmission, dict): diff --git a/leetcode/models/test_submission_result.py b/leetcode/models/test_submission_result.py index 5ba9ecb..9a01eba 100644 --- a/leetcode/models/test_submission_result.py +++ b/leetcode/models/test_submission_result.py @@ -14,13 +14,18 @@ import re # noqa: F401 import six -from leetcode.models.base_submission_result import BaseSubmissionResult # noqa: F401,E501 + +from leetcode.models.base_submission_result import ( # noqa: F401,E501 + BaseSubmissionResult, +) + class TestSubmissionResult(BaseSubmissionResult): """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ + """ Attributes: swagger_types (dict): The key is attribute name @@ -29,38 +34,53 @@ class TestSubmissionResult(BaseSubmissionResult): and the value is json key in definition. """ swagger_types = { - 'code_answer': 'list[str]', - 'correct_answer': 'bool', - 'expected_status_code': 'int', - 'expected_lang': 'str', - 'expected_run_success': 'bool', - 'expected_status_runtime': 'str', - 'expected_memory': 'int', - 'expected_code_answer': 'list[str]', - 'expected_code_output': 'list[str]', - 'expected_elapsed_time': 'int', - 'expected_task_finish_time': 'int' + "code_answer": "list[str]", + "correct_answer": "bool", + "expected_status_code": "int", + "expected_lang": "str", + "expected_run_success": "bool", + "expected_status_runtime": "str", + "expected_memory": "int", + "expected_code_answer": "list[str]", + "expected_code_output": "list[str]", + "expected_elapsed_time": "int", + "expected_task_finish_time": "int", } if hasattr(BaseSubmissionResult, "swagger_types"): swagger_types.update(BaseSubmissionResult.swagger_types) attribute_map = { - 'code_answer': 'code_answer', - 'correct_answer': 'correct_answer', - 'expected_status_code': 'expected_status_code', - 'expected_lang': 'expected_lang', - 'expected_run_success': 'expected_run_success', - 'expected_status_runtime': 'expected_status_runtime', - 'expected_memory': 'expected_memory', - 'expected_code_answer': 'expected_code_answer', - 'expected_code_output': 'expected_code_output', - 'expected_elapsed_time': 'expected_elapsed_time', - 'expected_task_finish_time': 'expected_task_finish_time' + "code_answer": "code_answer", + "correct_answer": "correct_answer", + "expected_status_code": "expected_status_code", + "expected_lang": "expected_lang", + "expected_run_success": "expected_run_success", + "expected_status_runtime": "expected_status_runtime", + "expected_memory": "expected_memory", + "expected_code_answer": "expected_code_answer", + "expected_code_output": "expected_code_output", + "expected_elapsed_time": "expected_elapsed_time", + "expected_task_finish_time": "expected_task_finish_time", } if hasattr(BaseSubmissionResult, "attribute_map"): attribute_map.update(BaseSubmissionResult.attribute_map) - def __init__(self, code_answer=None, correct_answer=None, expected_status_code=None, expected_lang=None, expected_run_success=None, expected_status_runtime=None, expected_memory=None, expected_code_answer=None, expected_code_output=None, expected_elapsed_time=None, expected_task_finish_time=None, *args, **kwargs): # noqa: E501 + def __init__( + self, + code_answer=None, + correct_answer=None, + expected_status_code=None, + expected_lang=None, + expected_run_success=None, + expected_status_runtime=None, + expected_memory=None, + expected_code_answer=None, + expected_code_output=None, + expected_elapsed_time=None, + expected_task_finish_time=None, + *args, + **kwargs + ): # noqa: E501 """TestSubmissionResult - a model defined in Swagger""" # noqa: E501 self._code_answer = None self._correct_answer = None @@ -116,7 +136,9 @@ def code_answer(self, code_answer): :type: list[str] """ if code_answer is None: - raise ValueError("Invalid value for `code_answer`, must not be `None`") # noqa: E501 + raise ValueError( + "Invalid value for `code_answer`, must not be `None`" + ) # noqa: E501 self._code_answer = code_answer @@ -162,8 +184,9 @@ def expected_status_code(self, expected_status_code): allowed_values = [10, 11, 15] # noqa: E501 if expected_status_code not in allowed_values: raise ValueError( - "Invalid value for `expected_status_code` ({0}), must be one of {1}" # noqa: E501 - .format(expected_status_code, allowed_values) + "Invalid value for `expected_status_code` ({0}), must be one of {1}".format( # noqa: E501 + expected_status_code, allowed_values + ) ) self._expected_status_code = expected_status_code @@ -343,18 +366,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.swagger_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value if issubclass(TestSubmissionResult, dict): diff --git a/leetcode/rest.py b/leetcode/rest.py index 8eff75f..72c2265 100644 --- a/leetcode/rest.py +++ b/leetcode/rest.py @@ -19,6 +19,7 @@ import ssl import certifi + # python 2 and python 3 compatibility library import six from six.moves.urllib.parse import urlencode @@ -26,14 +27,13 @@ try: import urllib3 except ImportError: - raise ImportError('Swagger python client requires urllib3.') + raise ImportError("Swagger python client requires urllib3.") logger = logging.getLogger(__name__) class RESTResponse(io.IOBase): - def __init__(self, resp): self.urllib3_response = resp self.status = resp.status @@ -50,7 +50,6 @@ def getheader(self, name, default=None): class RESTClientObject(object): - def __init__(self, configuration, pools_size=4, maxsize=None): # urllib3.PoolManager will pass all kw parameters to connectionpool # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501 @@ -73,7 +72,9 @@ def __init__(self, configuration, pools_size=4, maxsize=None): addition_pool_args = {} if configuration.assert_hostname is not None: - addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501 + addition_pool_args[ + "assert_hostname" + ] = configuration.assert_hostname # noqa: E501 if maxsize is None: if configuration.connection_pool_maxsize is not None: @@ -104,9 +105,17 @@ def __init__(self, configuration, pools_size=4, maxsize=None): **addition_pool_args ) - def request(self, method, url, query_params=None, headers=None, - body=None, post_params=None, _preload_content=True, - _request_timeout=None): + def request( + self, + method, + url, + query_params=None, + headers=None, + body=None, + post_params=None, + _preload_content=True, + _request_timeout=None, + ): """Perform requests. :param method: http request method @@ -126,8 +135,7 @@ def request(self, method, url, query_params=None, headers=None, (connection, read) timeouts. """ method = method.upper() - assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', - 'PATCH', 'OPTIONS'] + assert method in ["GET", "HEAD", "DELETE", "POST", "PUT", "PATCH", "OPTIONS"] if post_params and body: raise ValueError( @@ -139,62 +147,74 @@ def request(self, method, url, query_params=None, headers=None, timeout = None if _request_timeout: - if isinstance(_request_timeout, (int, ) if six.PY3 else (int, long)): # noqa: E501,F821 + if isinstance( + _request_timeout, (int,) if six.PY3 else (int, long) + ): # noqa: E501,F821 timeout = urllib3.Timeout(total=_request_timeout) - elif (isinstance(_request_timeout, tuple) and - len(_request_timeout) == 2): + elif isinstance(_request_timeout, tuple) and len(_request_timeout) == 2: timeout = urllib3.Timeout( - connect=_request_timeout[0], read=_request_timeout[1]) + connect=_request_timeout[0], read=_request_timeout[1] + ) - if 'Content-Type' not in headers: - headers['Content-Type'] = 'application/json' + if "Content-Type" not in headers: + headers["Content-Type"] = "application/json" try: # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` - if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: + if method in ["POST", "PUT", "PATCH", "OPTIONS", "DELETE"]: if query_params: - url += '?' + urlencode(query_params) - if re.search('json', headers['Content-Type'], re.IGNORECASE): - request_body = '{}' + url += "?" + urlencode(query_params) + if re.search("json", headers["Content-Type"], re.IGNORECASE): + request_body = "{}" if body is not None: request_body = json.dumps(body) r = self.pool_manager.request( - method, url, + method, + url, body=request_body, preload_content=_preload_content, timeout=timeout, - headers=headers) - elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 + headers=headers, + ) + elif ( + headers["Content-Type"] == "application/x-www-form-urlencoded" + ): # noqa: E501 r = self.pool_manager.request( - method, url, + method, + url, fields=post_params, encode_multipart=False, preload_content=_preload_content, timeout=timeout, - headers=headers) - elif headers['Content-Type'] == 'multipart/form-data': + headers=headers, + ) + elif headers["Content-Type"] == "multipart/form-data": # must del headers['Content-Type'], or the correct # Content-Type which generated by urllib3 will be # overwritten. - del headers['Content-Type'] + del headers["Content-Type"] r = self.pool_manager.request( - method, url, + method, + url, fields=post_params, encode_multipart=True, preload_content=_preload_content, timeout=timeout, - headers=headers) + headers=headers, + ) # Pass a `string` parameter directly in the body to support # other content types than Json when `body` argument is # provided in serialized form elif isinstance(body, str): request_body = body r = self.pool_manager.request( - method, url, + method, + url, body=request_body, preload_content=_preload_content, timeout=timeout, - headers=headers) + headers=headers, + ) else: # Cannot generate the request from given parameters msg = """Cannot prepare a request message for provided @@ -203,11 +223,14 @@ def request(self, method, url, query_params=None, headers=None, raise ApiException(status=0, reason=msg) # For `GET`, `HEAD` else: - r = self.pool_manager.request(method, url, - fields=query_params, - preload_content=_preload_content, - timeout=timeout, - headers=headers) + r = self.pool_manager.request( + method, + url, + fields=query_params, + preload_content=_preload_content, + timeout=timeout, + headers=headers, + ) except urllib3.exceptions.SSLError as e: msg = "{0}\n{1}".format(type(e).__name__, str(e)) raise ApiException(status=0, reason=msg) @@ -218,7 +241,7 @@ def request(self, method, url, query_params=None, headers=None, # In the python 3, the response.data is bytes. # we need to decode it to string. if six.PY3: - r.data = r.data.decode('utf8') + r.data = r.data.decode("utf8") # log response body logger.debug("response body: %s", r.data) @@ -228,74 +251,145 @@ def request(self, method, url, query_params=None, headers=None, return r - def GET(self, url, headers=None, query_params=None, _preload_content=True, - _request_timeout=None): - return self.request("GET", url, - headers=headers, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - query_params=query_params) - - def HEAD(self, url, headers=None, query_params=None, _preload_content=True, - _request_timeout=None): - return self.request("HEAD", url, - headers=headers, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - query_params=query_params) - - def OPTIONS(self, url, headers=None, query_params=None, post_params=None, - body=None, _preload_content=True, _request_timeout=None): - return self.request("OPTIONS", url, - headers=headers, - query_params=query_params, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - - def DELETE(self, url, headers=None, query_params=None, body=None, - _preload_content=True, _request_timeout=None): - return self.request("DELETE", url, - headers=headers, - query_params=query_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - - def POST(self, url, headers=None, query_params=None, post_params=None, - body=None, _preload_content=True, _request_timeout=None): - return self.request("POST", url, - headers=headers, - query_params=query_params, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - - def PUT(self, url, headers=None, query_params=None, post_params=None, - body=None, _preload_content=True, _request_timeout=None): - return self.request("PUT", url, - headers=headers, - query_params=query_params, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - - def PATCH(self, url, headers=None, query_params=None, post_params=None, - body=None, _preload_content=True, _request_timeout=None): - return self.request("PATCH", url, - headers=headers, - query_params=query_params, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) + def GET( + self, + url, + headers=None, + query_params=None, + _preload_content=True, + _request_timeout=None, + ): + return self.request( + "GET", + url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params, + ) + + def HEAD( + self, + url, + headers=None, + query_params=None, + _preload_content=True, + _request_timeout=None, + ): + return self.request( + "HEAD", + url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params, + ) + + def OPTIONS( + self, + url, + headers=None, + query_params=None, + post_params=None, + body=None, + _preload_content=True, + _request_timeout=None, + ): + return self.request( + "OPTIONS", + url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body, + ) + + def DELETE( + self, + url, + headers=None, + query_params=None, + body=None, + _preload_content=True, + _request_timeout=None, + ): + return self.request( + "DELETE", + url, + headers=headers, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body, + ) + + def POST( + self, + url, + headers=None, + query_params=None, + post_params=None, + body=None, + _preload_content=True, + _request_timeout=None, + ): + return self.request( + "POST", + url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body, + ) + + def PUT( + self, + url, + headers=None, + query_params=None, + post_params=None, + body=None, + _preload_content=True, + _request_timeout=None, + ): + return self.request( + "PUT", + url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body, + ) + + def PATCH( + self, + url, + headers=None, + query_params=None, + post_params=None, + body=None, + _preload_content=True, + _request_timeout=None, + ): + return self.request( + "PATCH", + url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body, + ) class ApiException(Exception): - def __init__(self, status=None, reason=None, http_resp=None): if http_resp: self.status = http_resp.status @@ -310,11 +404,9 @@ def __init__(self, status=None, reason=None, http_resp=None): def __str__(self): """Custom error messages for exception""" - error_message = "({0})\n"\ - "Reason: {1}\n".format(self.status, self.reason) + error_message = "({0})\n" "Reason: {1}\n".format(self.status, self.reason) if self.headers: - error_message += "HTTP response headers: {0}\n".format( - self.headers) + error_message += "HTTP response headers: {0}\n".format(self.headers) if self.body: error_message += "HTTP response body: {0}\n".format(self.body) diff --git a/setup.generated.py b/setup.generated.py index 49b3b8d..8b740b2 100644 --- a/setup.generated.py +++ b/setup.generated.py @@ -10,7 +10,7 @@ Generated by: https://github.com/swagger-api/swagger-codegen.git """ -from setuptools import setup, find_packages # noqa: H301 +from setuptools import find_packages, setup # noqa: H301 NAME = "leetcode" VERSION = "1.0.0" @@ -35,5 +35,5 @@ include_package_data=True, long_description="""\ Leetcode API implementation. # noqa: E501 - """ + """, ) diff --git a/test/test_any_of_graphql_question_detail_solution.py b/test/test_any_of_graphql_question_detail_solution.py index 66f6d54..2ca13e2 100644 --- a/test/test_any_of_graphql_question_detail_solution.py +++ b/test/test_any_of_graphql_question_detail_solution.py @@ -15,7 +15,9 @@ import unittest import leetcode -from leetcode.models.any_of_graphql_question_detail_solution import AnyOfGraphqlQuestionDetailSolution # noqa: E501 +from leetcode.models.any_of_graphql_question_detail_solution import ( # noqa: E501 + AnyOfGraphqlQuestionDetailSolution, +) from leetcode.rest import ApiException @@ -35,5 +37,5 @@ def testAnyOfGraphqlQuestionDetailSolution(self): pass -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/test/test_base_submission_result.py b/test/test_base_submission_result.py index 36992ed..94e6c9d 100644 --- a/test/test_base_submission_result.py +++ b/test/test_base_submission_result.py @@ -35,5 +35,5 @@ def testBaseSubmissionResult(self): pass -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/test/test_default_api.py b/test/test_default_api.py index 5a2165a..91b85bb 100644 --- a/test/test_default_api.py +++ b/test/test_default_api.py @@ -29,35 +29,25 @@ def tearDown(self): pass def test_api_problems_topic_get(self): - """Test case for api_problems_topic_get - - """ + """Test case for api_problems_topic_get""" pass def test_graphql_post(self): - """Test case for graphql_post - - """ + """Test case for graphql_post""" pass def test_problems_problem_interpret_solution_post(self): - """Test case for problems_problem_interpret_solution_post - - """ + """Test case for problems_problem_interpret_solution_post""" pass def test_problems_problem_submit_post(self): - """Test case for problems_problem_submit_post - - """ + """Test case for problems_problem_submit_post""" pass def test_submissions_detail_id_check_get(self): - """Test case for submissions_detail_id_check_get - - """ + """Test case for submissions_detail_id_check_get""" pass -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/test/test_difficulty.py b/test/test_difficulty.py index b024a3c..ca69804 100644 --- a/test/test_difficulty.py +++ b/test/test_difficulty.py @@ -35,5 +35,5 @@ def testDifficulty(self): pass -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/test/test_graphql_data.py b/test/test_graphql_data.py index f8645f3..e91bb94 100644 --- a/test/test_graphql_data.py +++ b/test/test_graphql_data.py @@ -35,5 +35,5 @@ def testGraphqlData(self): pass -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/test/test_graphql_query.py b/test/test_graphql_query.py index 3907b04..d31cfae 100644 --- a/test/test_graphql_query.py +++ b/test/test_graphql_query.py @@ -35,5 +35,5 @@ def testGraphqlQuery(self): pass -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/test/test_graphql_query_variables.py b/test/test_graphql_query_variables.py index b7cdd3f..354cadb 100644 --- a/test/test_graphql_query_variables.py +++ b/test/test_graphql_query_variables.py @@ -35,5 +35,5 @@ def testGraphqlQueryVariables(self): pass -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/test/test_graphql_question_code_snippet.py b/test/test_graphql_question_code_snippet.py index df52df2..8f61b9a 100644 --- a/test/test_graphql_question_code_snippet.py +++ b/test/test_graphql_question_code_snippet.py @@ -15,7 +15,9 @@ import unittest import leetcode -from leetcode.models.graphql_question_code_snippet import GraphqlQuestionCodeSnippet # noqa: E501 +from leetcode.models.graphql_question_code_snippet import ( # noqa: E501 + GraphqlQuestionCodeSnippet, +) from leetcode.rest import ApiException @@ -35,5 +37,5 @@ def testGraphqlQuestionCodeSnippet(self): pass -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/test/test_graphql_question_contributor.py b/test/test_graphql_question_contributor.py index c56d8b2..4091865 100644 --- a/test/test_graphql_question_contributor.py +++ b/test/test_graphql_question_contributor.py @@ -15,7 +15,9 @@ import unittest import leetcode -from leetcode.models.graphql_question_contributor import GraphqlQuestionContributor # noqa: E501 +from leetcode.models.graphql_question_contributor import ( # noqa: E501 + GraphqlQuestionContributor, +) from leetcode.rest import ApiException @@ -35,5 +37,5 @@ def testGraphqlQuestionContributor(self): pass -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/test/test_graphql_question_detail.py b/test/test_graphql_question_detail.py index 2712188..4f98072 100644 --- a/test/test_graphql_question_detail.py +++ b/test/test_graphql_question_detail.py @@ -35,5 +35,5 @@ def testGraphqlQuestionDetail(self): pass -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/test/test_graphql_question_solution.py b/test/test_graphql_question_solution.py index 52ce96c..e632890 100644 --- a/test/test_graphql_question_solution.py +++ b/test/test_graphql_question_solution.py @@ -15,7 +15,9 @@ import unittest import leetcode -from leetcode.models.graphql_question_solution import GraphqlQuestionSolution # noqa: E501 +from leetcode.models.graphql_question_solution import ( # noqa: E501 + GraphqlQuestionSolution, +) from leetcode.rest import ApiException @@ -35,5 +37,5 @@ def testGraphqlQuestionSolution(self): pass -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/test/test_graphql_question_topic_tag.py b/test/test_graphql_question_topic_tag.py index 20ca986..6e8c437 100644 --- a/test/test_graphql_question_topic_tag.py +++ b/test/test_graphql_question_topic_tag.py @@ -15,7 +15,9 @@ import unittest import leetcode -from leetcode.models.graphql_question_topic_tag import GraphqlQuestionTopicTag # noqa: E501 +from leetcode.models.graphql_question_topic_tag import ( # noqa: E501 + GraphqlQuestionTopicTag, +) from leetcode.rest import ApiException @@ -35,5 +37,5 @@ def testGraphqlQuestionTopicTag(self): pass -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/test/test_graphql_response.py b/test/test_graphql_response.py index 628f319..6b58efc 100644 --- a/test/test_graphql_response.py +++ b/test/test_graphql_response.py @@ -35,5 +35,5 @@ def testGraphqlResponse(self): pass -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/test/test_graphql_user.py b/test/test_graphql_user.py index 865c323..01a2e57 100644 --- a/test/test_graphql_user.py +++ b/test/test_graphql_user.py @@ -35,5 +35,5 @@ def testGraphqlUser(self): pass -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/test/test_id.py b/test/test_id.py index 983c635..32ef61b 100644 --- a/test/test_id.py +++ b/test/test_id.py @@ -35,5 +35,5 @@ def testId(self): pass -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/test/test_inline_response200.py b/test/test_inline_response200.py index b3f966f..5e7157b 100644 --- a/test/test_inline_response200.py +++ b/test/test_inline_response200.py @@ -35,5 +35,5 @@ def testInlineResponse200(self): pass -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/test/test_interpretation.py b/test/test_interpretation.py index 8d100b7..29fd611 100644 --- a/test/test_interpretation.py +++ b/test/test_interpretation.py @@ -35,5 +35,5 @@ def testInterpretation(self): pass -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/test/test_one_ofid.py b/test/test_one_ofid.py index e026ae7..7e630fb 100644 --- a/test/test_one_ofid.py +++ b/test/test_one_ofid.py @@ -35,5 +35,5 @@ def testOneOfid(self): pass -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/test/test_one_ofinline_response200.py b/test/test_one_ofinline_response200.py index e841400..482aa95 100644 --- a/test/test_one_ofinline_response200.py +++ b/test/test_one_ofinline_response200.py @@ -15,7 +15,9 @@ import unittest import leetcode -from leetcode.models.one_ofinline_response200 import OneOfinlineResponse200 # noqa: E501 +from leetcode.models.one_ofinline_response200 import ( # noqa: E501 + OneOfinlineResponse200, +) from leetcode.rest import ApiException @@ -35,5 +37,5 @@ def testOneOfinlineResponse200(self): pass -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/test/test_problems.py b/test/test_problems.py index a8ed2fd..999db49 100644 --- a/test/test_problems.py +++ b/test/test_problems.py @@ -35,5 +35,5 @@ def testProblems(self): pass -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/test/test_stat.py b/test/test_stat.py index e0c579f..bc7a959 100644 --- a/test/test_stat.py +++ b/test/test_stat.py @@ -35,5 +35,5 @@ def testStat(self): pass -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/test/test_stat_status_pair.py b/test/test_stat_status_pair.py index f87460e..af43124 100644 --- a/test/test_stat_status_pair.py +++ b/test/test_stat_status_pair.py @@ -35,5 +35,5 @@ def testStatStatusPair(self): pass -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/test/test_submission.py b/test/test_submission.py index da2987c..9346c44 100644 --- a/test/test_submission.py +++ b/test/test_submission.py @@ -35,5 +35,5 @@ def testSubmission(self): pass -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/test/test_submission_id.py b/test/test_submission_id.py index 497bc40..739a8c7 100644 --- a/test/test_submission_id.py +++ b/test/test_submission_id.py @@ -35,5 +35,5 @@ def testSubmissionId(self): pass -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/test/test_submission_result.py b/test/test_submission_result.py index b5db560..b250eb4 100644 --- a/test/test_submission_result.py +++ b/test/test_submission_result.py @@ -35,5 +35,5 @@ def testSubmissionResult(self): pass -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/test/test_test_submission.py b/test/test_test_submission.py index 3987235..0ae9f9c 100644 --- a/test/test_test_submission.py +++ b/test/test_test_submission.py @@ -35,5 +35,5 @@ def testTestSubmission(self): pass -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/test/test_test_submission_result.py b/test/test_test_submission_result.py index 349be13..7437bb5 100644 --- a/test/test_test_submission_result.py +++ b/test/test_test_submission_result.py @@ -35,5 +35,5 @@ def testTestSubmissionResult(self): pass -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() From 7691bb090c7b438d6cf9aefba62352ba90174c0a Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Sat, 23 Oct 2021 00:53:38 +0100 Subject: [PATCH 07/24] Added inferred type annotations --- .pyre_configuration | 5 +++++ .../models/any_of_graphql_question_detail_solution.py | 11 ++++++----- leetcode/models/graphql_data.py | 11 ++++++----- leetcode/models/graphql_question_code_snippet.py | 11 ++++++----- leetcode/models/graphql_question_contributor.py | 11 ++++++----- leetcode/models/graphql_question_solution.py | 11 ++++++----- leetcode/models/graphql_question_topic_tag.py | 11 ++++++----- leetcode/models/graphql_user.py | 11 ++++++----- setup.py | 3 ++- test/test_any_of_graphql_question_detail_solution.py | 8 ++++---- test/test_graphql_data.py | 8 ++++---- test/test_graphql_question_code_snippet.py | 8 ++++---- test/test_graphql_question_contributor.py | 8 ++++---- test/test_graphql_question_solution.py | 8 ++++---- test/test_graphql_question_topic_tag.py | 8 ++++---- test/test_graphql_user.py | 8 ++++---- 16 files changed, 77 insertions(+), 64 deletions(-) create mode 100644 .pyre_configuration diff --git a/.pyre_configuration b/.pyre_configuration new file mode 100644 index 0000000..9573b80 --- /dev/null +++ b/.pyre_configuration @@ -0,0 +1,5 @@ +{ + "source_directories": [ + "." + ] +} diff --git a/leetcode/models/any_of_graphql_question_detail_solution.py b/leetcode/models/any_of_graphql_question_detail_solution.py index 656e254..7ece360 100644 --- a/leetcode/models/any_of_graphql_question_detail_solution.py +++ b/leetcode/models/any_of_graphql_question_detail_solution.py @@ -9,6 +9,7 @@ Contact: pv.safronov@gmail.com Generated by: https://github.com/swagger-api/swagger-codegen.git """ +from __future__ import annotations import pprint import re # noqa: F401 @@ -33,7 +34,7 @@ class AnyOfGraphqlQuestionDetailSolution(object): attribute_map = {} - def __init__(self): # noqa: E501 + def __init__(self) -> None: # noqa: E501 """AnyOfGraphqlQuestionDetailSolution - a model defined in Swagger""" # noqa: E501 self.discriminator = None @@ -66,21 +67,21 @@ def to_dict(self): return result - def to_str(self): + def to_str(self) -> str: """Returns the string representation of the model""" return pprint.pformat(self.to_dict()) - def __repr__(self): + def __repr__(self) -> str: """For `print` and `pprint`""" return self.to_str() - def __eq__(self, other): + def __eq__(self, other: AnyOfGraphqlQuestionDetailSolution) -> bool: """Returns true if both objects are equal""" if not isinstance(other, AnyOfGraphqlQuestionDetailSolution): return False return self.__dict__ == other.__dict__ - def __ne__(self, other): + def __ne__(self, other) -> bool: """Returns true if both objects are not equal""" return not self == other diff --git a/leetcode/models/graphql_data.py b/leetcode/models/graphql_data.py index 5a6b6be..3562cbe 100644 --- a/leetcode/models/graphql_data.py +++ b/leetcode/models/graphql_data.py @@ -9,6 +9,7 @@ Contact: pv.safronov@gmail.com Generated by: https://github.com/swagger-api/swagger-codegen.git """ +from __future__ import annotations import pprint import re # noqa: F401 @@ -33,7 +34,7 @@ class GraphqlData(object): attribute_map = {"question": "question", "user": "user"} - def __init__(self, question=None, user=None): # noqa: E501 + def __init__(self, question=None, user=None) -> None: # noqa: E501 """GraphqlData - a model defined in Swagger""" # noqa: E501 self._question = None self._user = None @@ -114,21 +115,21 @@ def to_dict(self): return result - def to_str(self): + def to_str(self) -> str: """Returns the string representation of the model""" return pprint.pformat(self.to_dict()) - def __repr__(self): + def __repr__(self) -> str: """For `print` and `pprint`""" return self.to_str() - def __eq__(self, other): + def __eq__(self, other: GraphqlData) -> bool: """Returns true if both objects are equal""" if not isinstance(other, GraphqlData): return False return self.__dict__ == other.__dict__ - def __ne__(self, other): + def __ne__(self, other) -> bool: """Returns true if both objects are not equal""" return not self == other diff --git a/leetcode/models/graphql_question_code_snippet.py b/leetcode/models/graphql_question_code_snippet.py index a7a3b8e..6da43c8 100644 --- a/leetcode/models/graphql_question_code_snippet.py +++ b/leetcode/models/graphql_question_code_snippet.py @@ -9,6 +9,7 @@ Contact: pv.safronov@gmail.com Generated by: https://github.com/swagger-api/swagger-codegen.git """ +from __future__ import annotations import pprint import re # noqa: F401 @@ -45,7 +46,7 @@ class GraphqlQuestionCodeSnippet(object): def __init__( self, lang=None, lang_slug=None, code=None, typename=None - ): # noqa: E501 + ) -> None: # noqa: E501 """GraphqlQuestionCodeSnippet - a model defined in Swagger""" # noqa: E501 self._lang = None self._lang_slug = None @@ -183,21 +184,21 @@ def to_dict(self): return result - def to_str(self): + def to_str(self) -> str: """Returns the string representation of the model""" return pprint.pformat(self.to_dict()) - def __repr__(self): + def __repr__(self) -> str: """For `print` and `pprint`""" return self.to_str() - def __eq__(self, other): + def __eq__(self, other: GraphqlQuestionCodeSnippet) -> bool: """Returns true if both objects are equal""" if not isinstance(other, GraphqlQuestionCodeSnippet): return False return self.__dict__ == other.__dict__ - def __ne__(self, other): + def __ne__(self, other) -> bool: """Returns true if both objects are not equal""" return not self == other diff --git a/leetcode/models/graphql_question_contributor.py b/leetcode/models/graphql_question_contributor.py index 5f3842a..71bf078 100644 --- a/leetcode/models/graphql_question_contributor.py +++ b/leetcode/models/graphql_question_contributor.py @@ -9,6 +9,7 @@ Contact: pv.safronov@gmail.com Generated by: https://github.com/swagger-api/swagger-codegen.git """ +from __future__ import annotations import pprint import re # noqa: F401 @@ -45,7 +46,7 @@ class GraphqlQuestionContributor(object): def __init__( self, username=None, profile_url=None, avatar_url=None, typename=None - ): # noqa: E501 + ) -> None: # noqa: E501 """GraphqlQuestionContributor - a model defined in Swagger""" # noqa: E501 self._username = None self._profile_url = None @@ -183,21 +184,21 @@ def to_dict(self): return result - def to_str(self): + def to_str(self) -> str: """Returns the string representation of the model""" return pprint.pformat(self.to_dict()) - def __repr__(self): + def __repr__(self) -> str: """For `print` and `pprint`""" return self.to_str() - def __eq__(self, other): + def __eq__(self, other: GraphqlQuestionContributor) -> bool: """Returns true if both objects are equal""" if not isinstance(other, GraphqlQuestionContributor): return False return self.__dict__ == other.__dict__ - def __ne__(self, other): + def __ne__(self, other) -> bool: """Returns true if both objects are not equal""" return not self == other diff --git a/leetcode/models/graphql_question_solution.py b/leetcode/models/graphql_question_solution.py index b3d122b..56d9f53 100644 --- a/leetcode/models/graphql_question_solution.py +++ b/leetcode/models/graphql_question_solution.py @@ -9,6 +9,7 @@ Contact: pv.safronov@gmail.com Generated by: https://github.com/swagger-api/swagger-codegen.git """ +from __future__ import annotations import pprint import re # noqa: F401 @@ -37,7 +38,7 @@ class GraphqlQuestionSolution(object): "typename": "__typename", } - def __init__(self, id=None, can_see_detail=None, typename=None): # noqa: E501 + def __init__(self, id=None, can_see_detail=None, typename=None) -> None: # noqa: E501 """GraphqlQuestionSolution - a model defined in Swagger""" # noqa: E501 self._id = None self._can_see_detail = None @@ -149,21 +150,21 @@ def to_dict(self): return result - def to_str(self): + def to_str(self) -> str: """Returns the string representation of the model""" return pprint.pformat(self.to_dict()) - def __repr__(self): + def __repr__(self) -> str: """For `print` and `pprint`""" return self.to_str() - def __eq__(self, other): + def __eq__(self, other: GraphqlQuestionSolution) -> bool: """Returns true if both objects are equal""" if not isinstance(other, GraphqlQuestionSolution): return False return self.__dict__ == other.__dict__ - def __ne__(self, other): + def __ne__(self, other) -> bool: """Returns true if both objects are not equal""" return not self == other diff --git a/leetcode/models/graphql_question_topic_tag.py b/leetcode/models/graphql_question_topic_tag.py index 15c9934..75bad1c 100644 --- a/leetcode/models/graphql_question_topic_tag.py +++ b/leetcode/models/graphql_question_topic_tag.py @@ -9,6 +9,7 @@ Contact: pv.safronov@gmail.com Generated by: https://github.com/swagger-api/swagger-codegen.git """ +from __future__ import annotations import pprint import re # noqa: F401 @@ -45,7 +46,7 @@ class GraphqlQuestionTopicTag(object): def __init__( self, name=None, slug=None, translated_name=None, typename=None - ): # noqa: E501 + ) -> None: # noqa: E501 """GraphqlQuestionTopicTag - a model defined in Swagger""" # noqa: E501 self._name = None self._slug = None @@ -180,21 +181,21 @@ def to_dict(self): return result - def to_str(self): + def to_str(self) -> str: """Returns the string representation of the model""" return pprint.pformat(self.to_dict()) - def __repr__(self): + def __repr__(self) -> str: """For `print` and `pprint`""" return self.to_str() - def __eq__(self, other): + def __eq__(self, other: GraphqlQuestionTopicTag) -> bool: """Returns true if both objects are equal""" if not isinstance(other, GraphqlQuestionTopicTag): return False return self.__dict__ == other.__dict__ - def __ne__(self, other): + def __ne__(self, other) -> bool: """Returns true if both objects are not equal""" return not self == other diff --git a/leetcode/models/graphql_user.py b/leetcode/models/graphql_user.py index 4f3d1fd..0c98fd3 100644 --- a/leetcode/models/graphql_user.py +++ b/leetcode/models/graphql_user.py @@ -9,6 +9,7 @@ Contact: pv.safronov@gmail.com Generated by: https://github.com/swagger-api/swagger-codegen.git """ +from __future__ import annotations import pprint import re # noqa: F401 @@ -36,7 +37,7 @@ class GraphqlUser(object): "is_current_user_premium": "isCurrentUserPremium", } - def __init__(self, username=None, is_current_user_premium=None): # noqa: E501 + def __init__(self, username=None, is_current_user_premium=None) -> None: # noqa: E501 """GraphqlUser - a model defined in Swagger""" # noqa: E501 self._username = None self._is_current_user_premium = None @@ -117,21 +118,21 @@ def to_dict(self): return result - def to_str(self): + def to_str(self) -> str: """Returns the string representation of the model""" return pprint.pformat(self.to_dict()) - def __repr__(self): + def __repr__(self) -> str: """For `print` and `pprint`""" return self.to_str() - def __eq__(self, other): + def __eq__(self, other: GraphqlUser) -> bool: """Returns true if both objects are equal""" if not isinstance(other, GraphqlUser): return False return self.__dict__ == other.__dict__ - def __ne__(self, other): + def __ne__(self, other) -> bool: """Returns true if both objects are not equal""" return not self == other diff --git a/setup.py b/setup.py index c7d9d86..a57af48 100644 --- a/setup.py +++ b/setup.py @@ -9,13 +9,14 @@ Contact: pv.safronov@gmail.com Generated by: https://github.com/swagger-api/swagger-codegen.git """ +from __future__ import annotations from setuptools import find_packages, setup # noqa: H301 NAME = "python-leetcode" VERSION = "1.0.10" with open("README.md") as readme: - DESCRIPTION = readme.read() + DESCRIPTION: str = readme.read() # To install the library, run the following # diff --git a/test/test_any_of_graphql_question_detail_solution.py b/test/test_any_of_graphql_question_detail_solution.py index 2ca13e2..2b0f0c9 100644 --- a/test/test_any_of_graphql_question_detail_solution.py +++ b/test/test_any_of_graphql_question_detail_solution.py @@ -10,7 +10,7 @@ Generated by: https://github.com/swagger-api/swagger-codegen.git """ -from __future__ import absolute_import +from __future__ import annotations, absolute_import import unittest @@ -24,13 +24,13 @@ class TestAnyOfGraphqlQuestionDetailSolution(unittest.TestCase): """AnyOfGraphqlQuestionDetailSolution unit test stubs""" - def setUp(self): + def setUp(self) -> None: pass - def tearDown(self): + def tearDown(self) -> None: pass - def testAnyOfGraphqlQuestionDetailSolution(self): + def testAnyOfGraphqlQuestionDetailSolution(self) -> None: """Test AnyOfGraphqlQuestionDetailSolution""" # FIXME: construct object with mandatory attributes with example values # model = leetcode.models.any_of_graphql_question_detail_solution.AnyOfGraphqlQuestionDetailSolution() # noqa: E501 diff --git a/test/test_graphql_data.py b/test/test_graphql_data.py index e91bb94..35c4ac5 100644 --- a/test/test_graphql_data.py +++ b/test/test_graphql_data.py @@ -10,7 +10,7 @@ Generated by: https://github.com/swagger-api/swagger-codegen.git """ -from __future__ import absolute_import +from __future__ import annotations, absolute_import import unittest @@ -22,13 +22,13 @@ class TestGraphqlData(unittest.TestCase): """GraphqlData unit test stubs""" - def setUp(self): + def setUp(self) -> None: pass - def tearDown(self): + def tearDown(self) -> None: pass - def testGraphqlData(self): + def testGraphqlData(self) -> None: """Test GraphqlData""" # FIXME: construct object with mandatory attributes with example values # model = leetcode.models.graphql_data.GraphqlData() # noqa: E501 diff --git a/test/test_graphql_question_code_snippet.py b/test/test_graphql_question_code_snippet.py index 8f61b9a..71638c5 100644 --- a/test/test_graphql_question_code_snippet.py +++ b/test/test_graphql_question_code_snippet.py @@ -10,7 +10,7 @@ Generated by: https://github.com/swagger-api/swagger-codegen.git """ -from __future__ import absolute_import +from __future__ import annotations, absolute_import import unittest @@ -24,13 +24,13 @@ class TestGraphqlQuestionCodeSnippet(unittest.TestCase): """GraphqlQuestionCodeSnippet unit test stubs""" - def setUp(self): + def setUp(self) -> None: pass - def tearDown(self): + def tearDown(self) -> None: pass - def testGraphqlQuestionCodeSnippet(self): + def testGraphqlQuestionCodeSnippet(self) -> None: """Test GraphqlQuestionCodeSnippet""" # FIXME: construct object with mandatory attributes with example values # model = leetcode.models.graphql_question_code_snippet.GraphqlQuestionCodeSnippet() # noqa: E501 diff --git a/test/test_graphql_question_contributor.py b/test/test_graphql_question_contributor.py index 4091865..5b2e60a 100644 --- a/test/test_graphql_question_contributor.py +++ b/test/test_graphql_question_contributor.py @@ -10,7 +10,7 @@ Generated by: https://github.com/swagger-api/swagger-codegen.git """ -from __future__ import absolute_import +from __future__ import annotations, absolute_import import unittest @@ -24,13 +24,13 @@ class TestGraphqlQuestionContributor(unittest.TestCase): """GraphqlQuestionContributor unit test stubs""" - def setUp(self): + def setUp(self) -> None: pass - def tearDown(self): + def tearDown(self) -> None: pass - def testGraphqlQuestionContributor(self): + def testGraphqlQuestionContributor(self) -> None: """Test GraphqlQuestionContributor""" # FIXME: construct object with mandatory attributes with example values # model = leetcode.models.graphql_question_contributor.GraphqlQuestionContributor() # noqa: E501 diff --git a/test/test_graphql_question_solution.py b/test/test_graphql_question_solution.py index e632890..5667853 100644 --- a/test/test_graphql_question_solution.py +++ b/test/test_graphql_question_solution.py @@ -10,7 +10,7 @@ Generated by: https://github.com/swagger-api/swagger-codegen.git """ -from __future__ import absolute_import +from __future__ import annotations, absolute_import import unittest @@ -24,13 +24,13 @@ class TestGraphqlQuestionSolution(unittest.TestCase): """GraphqlQuestionSolution unit test stubs""" - def setUp(self): + def setUp(self) -> None: pass - def tearDown(self): + def tearDown(self) -> None: pass - def testGraphqlQuestionSolution(self): + def testGraphqlQuestionSolution(self) -> None: """Test GraphqlQuestionSolution""" # FIXME: construct object with mandatory attributes with example values # model = leetcode.models.graphql_question_solution.GraphqlQuestionSolution() # noqa: E501 diff --git a/test/test_graphql_question_topic_tag.py b/test/test_graphql_question_topic_tag.py index 6e8c437..9884de0 100644 --- a/test/test_graphql_question_topic_tag.py +++ b/test/test_graphql_question_topic_tag.py @@ -10,7 +10,7 @@ Generated by: https://github.com/swagger-api/swagger-codegen.git """ -from __future__ import absolute_import +from __future__ import annotations, absolute_import import unittest @@ -24,13 +24,13 @@ class TestGraphqlQuestionTopicTag(unittest.TestCase): """GraphqlQuestionTopicTag unit test stubs""" - def setUp(self): + def setUp(self) -> None: pass - def tearDown(self): + def tearDown(self) -> None: pass - def testGraphqlQuestionTopicTag(self): + def testGraphqlQuestionTopicTag(self) -> None: """Test GraphqlQuestionTopicTag""" # FIXME: construct object with mandatory attributes with example values # model = leetcode.models.graphql_question_topic_tag.GraphqlQuestionTopicTag() # noqa: E501 diff --git a/test/test_graphql_user.py b/test/test_graphql_user.py index 01a2e57..9e07da2 100644 --- a/test/test_graphql_user.py +++ b/test/test_graphql_user.py @@ -10,7 +10,7 @@ Generated by: https://github.com/swagger-api/swagger-codegen.git """ -from __future__ import absolute_import +from __future__ import annotations, absolute_import import unittest @@ -22,13 +22,13 @@ class TestGraphqlUser(unittest.TestCase): """GraphqlUser unit test stubs""" - def setUp(self): + def setUp(self) -> None: pass - def tearDown(self): + def tearDown(self) -> None: pass - def testGraphqlUser(self): + def testGraphqlUser(self) -> None: """Test GraphqlUser""" # FIXME: construct object with mandatory attributes with example values # model = leetcode.models.graphql_user.GraphqlUser() # noqa: E501 From a040ff0d6d7073fcb39b22908c0cac7f0559cb97 Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Sat, 23 Oct 2021 01:24:24 +0100 Subject: [PATCH 08/24] Fix pyre type errors --- example.py | 14 +++++--- test/base.py | 34 ++++++++++++++++--- ...est_graphql_request_get_question_detail.py | 15 ++++---- 3 files changed, 48 insertions(+), 15 deletions(-) diff --git a/example.py b/example.py index 0751534..3a29181 100644 --- a/example.py +++ b/example.py @@ -1,18 +1,22 @@ +import os import sys from time import sleep -from cookies import cookies - import leetcode +import leetcode.auth # Initialize client configuration = leetcode.Configuration() # NOTE: cookies var is just a dict with `csrftoken` and `LEETCODE_SESSION` # fields which contain corresponding cookies from web browser -configuration.api_key["x-csrftoken"] = cookies["csrftoken"] -configuration.api_key["csrftoken"] = cookies["csrftoken"] -configuration.api_key["LEETCODE_SESSION"] = cookies["LEETCODE_SESSION"] +leetcode_session = os.environ["LEETCODE_SESSION_ID"] + +csrf_token = leetcode.auth.get_csrf_cookie(leetcode_session) + +configuration.api_key["x-csrftoken"] = csrf_token +configuration.api_key["csrftoken"] = csrf_token +configuration.api_key["LEETCODE_SESSION"] = leetcode_session configuration.api_key["Referer"] = "https://leetcode.com" configuration.debug = False diff --git a/test/base.py b/test/base.py index adeee2b..dca44f6 100644 --- a/test/base.py +++ b/test/base.py @@ -1,15 +1,35 @@ import os +from typing import Optional -import leetcode +import leetcode.api.default_api +import leetcode.api_client import leetcode.auth +import leetcode.configuration class BaseTest: + _api_instance_containter: Optional[leetcode.api.default_api.DefaultApi] = None + + @property + def _api_instance(self) -> leetcode.api.default_api.DefaultApi: + api_instance = self._api_instance_containter + + if api_instance is None: + raise RuntimeError("Api instance is not initialized") + + return api_instance + + @_api_instance.setter + def _api_instance( + self, value: Optional[leetcode.api.default_api.DefaultApi] + ) -> None: + self._api_instance_containter = value + def setup(self) -> None: session_id = os.environ["LEETCODE_SESSION_ID"] csrftoken = leetcode.auth.get_csrf_cookie(session_id) - configuration = leetcode.Configuration() + configuration = leetcode.configuration.Configuration() configuration.api_key["x-csrftoken"] = csrftoken configuration.api_key["csrftoken"] = csrftoken @@ -18,7 +38,13 @@ def setup(self) -> None: configuration.debug = False - self._api_instance = leetcode.DefaultApi(leetcode.ApiClient(configuration)) + self._api_instance = leetcode.api.default_api.DefaultApi( + leetcode.api_client.ApiClient(configuration) + ) def teardown(self) -> None: - pass + api_instance = self._api_instance + + del api_instance + + self._api_instance = None diff --git a/test/test_graphql_request_get_question_detail.py b/test/test_graphql_request_get_question_detail.py index dd7c5af..2c0991e 100644 --- a/test/test_graphql_request_get_question_detail.py +++ b/test/test_graphql_request_get_question_detail.py @@ -1,12 +1,15 @@ import json import test.base -import leetcode +from leetcode.models.graphql_query import GraphqlQuery +from leetcode.models.graphql_query_variables import GraphqlQueryVariables +from leetcode.models.graphql_question_code_snippet import GraphqlQuestionCodeSnippet +from leetcode.models.graphql_question_topic_tag import GraphqlQuestionTopicTag class TestGraphqlGetQuestionDetail(test.base.BaseTest): def test_request(self) -> None: - graphql_request = leetcode.GraphqlQuery( + graphql_request = GraphqlQuery( query=""" query getQuestionDetail($titleSlug: String!) { question(titleSlug: $titleSlug) { @@ -70,7 +73,7 @@ def test_request(self) -> None: } } """, - variables=leetcode.GraphqlQueryVariables(title_slug="two-sum"), + variables=GraphqlQueryVariables(title_slug="two-sum"), operation_name="getQuestionDetail", ) @@ -107,7 +110,7 @@ def test_request(self) -> None: assert len(question.contributors) == 0 assert "python" in list(json.loads(question.lang_to_valid_playground).keys()) topic_tag = question.topic_tags[0] - assert isinstance(topic_tag, leetcode.GraphqlQuestionTopicTag) + assert isinstance(topic_tag, GraphqlQuestionTopicTag) assert len(topic_tag.name) > 0 assert len(topic_tag.slug) > 0 assert question.topic_tags[0].translated_name is None @@ -122,7 +125,7 @@ def test_request(self) -> None: code_snippet = question.code_snippets[0] - assert isinstance(code_snippet, leetcode.GraphqlQuestionCodeSnippet) + assert isinstance(code_snippet, GraphqlQuestionCodeSnippet) assert len(code_snippet.code) > 0 assert len(code_snippet.lang) > 0 assert len(code_snippet.lang_slug) > 0 @@ -148,7 +151,7 @@ def test_request(self) -> None: solution = question.solution # FIXME: this check doesn't work with swagger generated code - # assert isinstance(solution, leetcode.GraphqlQuestionSolution) + # assert isinstance(solution, GraphqlQuestionSolution) # FIXME: swagger generates the code which returns dict assert solution["__typename"] == "ArticleNode" From fd72c1d37631ccb0af9ae38c3e3181b2e1d28092 Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Mon, 25 Oct 2021 13:08:19 +0100 Subject: [PATCH 09/24] Added new graphql request (no backwards compatibility from here) --- README.generated.md | 5 + docs/AnyOfGraphqlQueryVariables.md | 8 + docs/GraphqlData.md | 1 + docs/GraphqlProblemsetQuestionList.md | 10 + docs/GraphqlQuery.md | 2 +- .../GraphqlQueryGetQuestionDetailVariables.md | 9 + ...hqlQueryProblemsetQuestionListVariables.md | 12 + ...blemsetQuestionListVariablesFilterInput.md | 13 + docs/GraphqlQueryVariables.md | 1 - example.py | 6 +- leetcode/__init__.py | 13 + leetcode/models/__init__.py | 13 + .../models/any_of_graphql_query_variables.py | 87 +++++++ leetcode/models/graphql_data.py | 44 +++- .../graphql_problemset_question_list.py | 135 +++++++++++ leetcode/models/graphql_query.py | 6 +- ...hql_query_get_question_detail_variables.py | 111 +++++++++ ...uery_problemset_question_list_variables.py | 195 +++++++++++++++ ...et_question_list_variables_filter_input.py | 225 ++++++++++++++++++ leetcode/models/graphql_query_variables.py | 30 +-- leetcode/models/graphql_question_solution.py | 4 +- leetcode/models/graphql_user.py | 4 +- setup.py | 3 +- test/test_any_of_graphql_query_variables.py | 41 ++++ ...any_of_graphql_question_detail_solution.py | 2 +- test/test_graphql_data.py | 2 +- test/test_graphql_problemset_question_list.py | 41 ++++ ...hql_query_get_question_detail_variables.py | 41 ++++ ...uery_problemset_question_list_variables.py | 41 ++++ ...et_question_list_variables_filter_input.py | 41 ++++ test/test_graphql_question_code_snippet.py | 2 +- test/test_graphql_question_contributor.py | 2 +- test/test_graphql_question_solution.py | 2 +- test/test_graphql_question_topic_tag.py | 2 +- ...est_graphql_request_get_question_detail.py | 10 +- ...raphql_request_problemset_question_list.py | 210 ++++++++++++++++ test/test_graphql_request_user.py | 4 +- test/test_graphql_user.py | 2 +- 38 files changed, 1327 insertions(+), 53 deletions(-) create mode 100644 docs/AnyOfGraphqlQueryVariables.md create mode 100644 docs/GraphqlProblemsetQuestionList.md create mode 100644 docs/GraphqlQueryGetQuestionDetailVariables.md create mode 100644 docs/GraphqlQueryProblemsetQuestionListVariables.md create mode 100644 docs/GraphqlQueryProblemsetQuestionListVariablesFilterInput.md create mode 100644 leetcode/models/any_of_graphql_query_variables.py create mode 100644 leetcode/models/graphql_problemset_question_list.py create mode 100644 leetcode/models/graphql_query_get_question_detail_variables.py create mode 100644 leetcode/models/graphql_query_problemset_question_list_variables.py create mode 100644 leetcode/models/graphql_query_problemset_question_list_variables_filter_input.py create mode 100644 test/test_any_of_graphql_query_variables.py create mode 100644 test/test_graphql_problemset_question_list.py create mode 100644 test/test_graphql_query_get_question_detail_variables.py create mode 100644 test/test_graphql_query_problemset_question_list_variables.py create mode 100644 test/test_graphql_query_problemset_question_list_variables_filter_input.py create mode 100644 test/test_graphql_request_problemset_question_list.py diff --git a/README.generated.md b/README.generated.md index 1e09d88..248de56 100644 --- a/README.generated.md +++ b/README.generated.md @@ -223,11 +223,16 @@ Class | Method | HTTP request | Description ## Documentation For Models + - [AnyOfGraphqlQueryVariables](docs/AnyOfGraphqlQueryVariables.md) - [AnyOfGraphqlQuestionDetailSolution](docs/AnyOfGraphqlQuestionDetailSolution.md) - [BaseSubmissionResult](docs/BaseSubmissionResult.md) - [Difficulty](docs/Difficulty.md) - [GraphqlData](docs/GraphqlData.md) + - [GraphqlProblemsetQuestionList](docs/GraphqlProblemsetQuestionList.md) - [GraphqlQuery](docs/GraphqlQuery.md) + - [GraphqlQueryGetQuestionDetailVariables](docs/GraphqlQueryGetQuestionDetailVariables.md) + - [GraphqlQueryProblemsetQuestionListVariables](docs/GraphqlQueryProblemsetQuestionListVariables.md) + - [GraphqlQueryProblemsetQuestionListVariablesFilterInput](docs/GraphqlQueryProblemsetQuestionListVariablesFilterInput.md) - [GraphqlQueryVariables](docs/GraphqlQueryVariables.md) - [GraphqlQuestionCodeSnippet](docs/GraphqlQuestionCodeSnippet.md) - [GraphqlQuestionContributor](docs/GraphqlQuestionContributor.md) diff --git a/docs/AnyOfGraphqlQueryVariables.md b/docs/AnyOfGraphqlQueryVariables.md new file mode 100644 index 0000000..e310fe2 --- /dev/null +++ b/docs/AnyOfGraphqlQueryVariables.md @@ -0,0 +1,8 @@ +# AnyOfGraphqlQueryVariables + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/docs/GraphqlData.md b/docs/GraphqlData.md index a95ab84..549dc26 100644 --- a/docs/GraphqlData.md +++ b/docs/GraphqlData.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **question** | [**GraphqlQuestionDetail**](GraphqlQuestionDetail.md) | | [optional] **user** | [**GraphqlUser**](GraphqlUser.md) | | [optional] +**problemset_question_list** | [**GraphqlProblemsetQuestionList**](GraphqlProblemsetQuestionList.md) | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/GraphqlProblemsetQuestionList.md b/docs/GraphqlProblemsetQuestionList.md new file mode 100644 index 0000000..5253478 --- /dev/null +++ b/docs/GraphqlProblemsetQuestionList.md @@ -0,0 +1,10 @@ +# GraphqlProblemsetQuestionList + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**total** | **int** | | [optional] +**questions** | [**list[GraphqlQuestionDetail]**](GraphqlQuestionDetail.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/docs/GraphqlQuery.md b/docs/GraphqlQuery.md index 29a35b3..b0bf2f1 100644 --- a/docs/GraphqlQuery.md +++ b/docs/GraphqlQuery.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **query** | **str** | | -**variables** | [**GraphqlQueryVariables**](GraphqlQueryVariables.md) | | +**variables** | [**AnyOfGraphqlQueryVariables**](AnyOfGraphqlQueryVariables.md) | | **operation_name** | **str** | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/GraphqlQueryGetQuestionDetailVariables.md b/docs/GraphqlQueryGetQuestionDetailVariables.md new file mode 100644 index 0000000..b56e29f --- /dev/null +++ b/docs/GraphqlQueryGetQuestionDetailVariables.md @@ -0,0 +1,9 @@ +# GraphqlQueryGetQuestionDetailVariables + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**title_slug** | **str** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/docs/GraphqlQueryProblemsetQuestionListVariables.md b/docs/GraphqlQueryProblemsetQuestionListVariables.md new file mode 100644 index 0000000..ee50a54 --- /dev/null +++ b/docs/GraphqlQueryProblemsetQuestionListVariables.md @@ -0,0 +1,12 @@ +# GraphqlQueryProblemsetQuestionListVariables + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**category_slug** | **str** | | [optional] +**limit** | **int** | | [optional] +**skip** | **int** | | [optional] +**filters** | [**GraphqlQueryProblemsetQuestionListVariablesFilterInput**](GraphqlQueryProblemsetQuestionListVariablesFilterInput.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/docs/GraphqlQueryProblemsetQuestionListVariablesFilterInput.md b/docs/GraphqlQueryProblemsetQuestionListVariablesFilterInput.md new file mode 100644 index 0000000..ec69410 --- /dev/null +++ b/docs/GraphqlQueryProblemsetQuestionListVariablesFilterInput.md @@ -0,0 +1,13 @@ +# GraphqlQueryProblemsetQuestionListVariablesFilterInput + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**tags** | **list[str]** | | [optional] +**difficulty** | **str** | | [optional] +**status** | **str** | | [optional] +**list_id** | **str** | | [optional] +**premium_only** | **bool** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/docs/GraphqlQueryVariables.md b/docs/GraphqlQueryVariables.md index cd77fc5..bd9a674 100644 --- a/docs/GraphqlQueryVariables.md +++ b/docs/GraphqlQueryVariables.md @@ -3,7 +3,6 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**title_slug** | **str** | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/example.py b/example.py index 3a29181..8d38d7d 100644 --- a/example.py +++ b/example.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import sys from time import sleep @@ -10,9 +12,9 @@ # NOTE: cookies var is just a dict with `csrftoken` and `LEETCODE_SESSION` # fields which contain corresponding cookies from web browser -leetcode_session = os.environ["LEETCODE_SESSION_ID"] +leetcode_session: str = os.environ["LEETCODE_SESSION_ID"] -csrf_token = leetcode.auth.get_csrf_cookie(leetcode_session) +csrf_token: str = leetcode.auth.get_csrf_cookie(leetcode_session) configuration.api_key["x-csrftoken"] = csrf_token configuration.api_key["csrftoken"] = csrf_token diff --git a/leetcode/__init__.py b/leetcode/__init__.py index 0bd925d..707af62 100644 --- a/leetcode/__init__.py +++ b/leetcode/__init__.py @@ -22,13 +22,26 @@ from leetcode.configuration import Configuration # import models into sdk package +from leetcode.models.any_of_graphql_query_variables import AnyOfGraphqlQueryVariables from leetcode.models.any_of_graphql_question_detail_solution import ( AnyOfGraphqlQuestionDetailSolution, ) from leetcode.models.base_submission_result import BaseSubmissionResult from leetcode.models.difficulty import Difficulty from leetcode.models.graphql_data import GraphqlData +from leetcode.models.graphql_problemset_question_list import ( + GraphqlProblemsetQuestionList, +) from leetcode.models.graphql_query import GraphqlQuery +from leetcode.models.graphql_query_get_question_detail_variables import ( + GraphqlQueryGetQuestionDetailVariables, +) +from leetcode.models.graphql_query_problemset_question_list_variables import ( + GraphqlQueryProblemsetQuestionListVariables, +) +from leetcode.models.graphql_query_problemset_question_list_variables_filter_input import ( + GraphqlQueryProblemsetQuestionListVariablesFilterInput, +) from leetcode.models.graphql_query_variables import GraphqlQueryVariables from leetcode.models.graphql_question_code_snippet import GraphqlQuestionCodeSnippet from leetcode.models.graphql_question_contributor import GraphqlQuestionContributor diff --git a/leetcode/models/__init__.py b/leetcode/models/__init__.py index a1cd290..de07276 100644 --- a/leetcode/models/__init__.py +++ b/leetcode/models/__init__.py @@ -14,13 +14,26 @@ from __future__ import absolute_import # import models into model package +from leetcode.models.any_of_graphql_query_variables import AnyOfGraphqlQueryVariables from leetcode.models.any_of_graphql_question_detail_solution import ( AnyOfGraphqlQuestionDetailSolution, ) from leetcode.models.base_submission_result import BaseSubmissionResult from leetcode.models.difficulty import Difficulty from leetcode.models.graphql_data import GraphqlData +from leetcode.models.graphql_problemset_question_list import ( + GraphqlProblemsetQuestionList, +) from leetcode.models.graphql_query import GraphqlQuery +from leetcode.models.graphql_query_get_question_detail_variables import ( + GraphqlQueryGetQuestionDetailVariables, +) +from leetcode.models.graphql_query_problemset_question_list_variables import ( + GraphqlQueryProblemsetQuestionListVariables, +) +from leetcode.models.graphql_query_problemset_question_list_variables_filter_input import ( + GraphqlQueryProblemsetQuestionListVariablesFilterInput, +) from leetcode.models.graphql_query_variables import GraphqlQueryVariables from leetcode.models.graphql_question_code_snippet import GraphqlQuestionCodeSnippet from leetcode.models.graphql_question_contributor import GraphqlQuestionContributor diff --git a/leetcode/models/any_of_graphql_query_variables.py b/leetcode/models/any_of_graphql_query_variables.py new file mode 100644 index 0000000..2fcc4d9 --- /dev/null +++ b/leetcode/models/any_of_graphql_query_variables.py @@ -0,0 +1,87 @@ +# coding: utf-8 + +""" + Leetcode API + + Leetcode API implementation. # noqa: E501 + + OpenAPI spec version: 1.0.1-1 + Contact: pv.safronov@gmail.com + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" +from __future__ import annotations + +import pprint +import re # noqa: F401 + +import six + + +class AnyOfGraphqlQueryVariables(object): + """NOTE: This class is auto generated by the swagger code generator program. + + Do not edit the class manually. + """ + + """ + Attributes: + swagger_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + swagger_types = {} + + attribute_map = {} + + def __init__(self) -> None: # noqa: E501 + """AnyOfGraphqlQueryVariables - a model defined in Swagger""" # noqa: E501 + self.discriminator = None + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) + else: + result[attr] = value + if issubclass(AnyOfGraphqlQueryVariables, dict): + for key, value in self.items(): + result[key] = value + + return result + + def to_str(self) -> str: + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self) -> str: + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other: AnyOfGraphqlQueryVariables) -> bool: + """Returns true if both objects are equal""" + if not isinstance(other, AnyOfGraphqlQueryVariables): + return False + + return self.__dict__ == other.__dict__ + + def __ne__(self, other) -> bool: + """Returns true if both objects are not equal""" + return not self == other diff --git a/leetcode/models/graphql_data.py b/leetcode/models/graphql_data.py index 3562cbe..5f8b66a 100644 --- a/leetcode/models/graphql_data.py +++ b/leetcode/models/graphql_data.py @@ -30,19 +30,32 @@ class GraphqlData(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - swagger_types = {"question": "GraphqlQuestionDetail", "user": "GraphqlUser"} - - attribute_map = {"question": "question", "user": "user"} - - def __init__(self, question=None, user=None) -> None: # noqa: E501 + swagger_types = { + "question": "GraphqlQuestionDetail", + "user": "GraphqlUser", + "problemset_question_list": "GraphqlProblemsetQuestionList", + } + + attribute_map = { + "question": "question", + "user": "user", + "problemset_question_list": "problemsetQuestionList", + } + + def __init__( + self, question=None, user=None, problemset_question_list=None + ) -> None: # noqa: E501 """GraphqlData - a model defined in Swagger""" # noqa: E501 self._question = None self._user = None + self._problemset_question_list = None self.discriminator = None if question is not None: self.question = question if user is not None: self.user = user + if problemset_question_list is not None: + self.problemset_question_list = problemset_question_list @property def question(self): @@ -86,6 +99,27 @@ def user(self, user): self._user = user + @property + def problemset_question_list(self): + """Gets the problemset_question_list of this GraphqlData. # noqa: E501 + + + :return: The problemset_question_list of this GraphqlData. # noqa: E501 + :rtype: GraphqlProblemsetQuestionList + """ + return self._problemset_question_list + + @problemset_question_list.setter + def problemset_question_list(self, problemset_question_list): + """Sets the problemset_question_list of this GraphqlData. + + + :param problemset_question_list: The problemset_question_list of this GraphqlData. # noqa: E501 + :type: GraphqlProblemsetQuestionList + """ + + self._problemset_question_list = problemset_question_list + def to_dict(self): """Returns the model properties as a dict""" result = {} diff --git a/leetcode/models/graphql_problemset_question_list.py b/leetcode/models/graphql_problemset_question_list.py new file mode 100644 index 0000000..890b1e1 --- /dev/null +++ b/leetcode/models/graphql_problemset_question_list.py @@ -0,0 +1,135 @@ +# coding: utf-8 + +""" + Leetcode API + + Leetcode API implementation. # noqa: E501 + + OpenAPI spec version: 1.0.1-1 + Contact: pv.safronov@gmail.com + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" +from __future__ import annotations + +import pprint +import re # noqa: F401 + +import six + + +class GraphqlProblemsetQuestionList(object): + """NOTE: This class is auto generated by the swagger code generator program. + + Do not edit the class manually. + """ + + """ + Attributes: + swagger_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + swagger_types = {"total": "int", "questions": "list[GraphqlQuestionDetail]"} + + attribute_map = {"total": "total", "questions": "questions"} + + def __init__(self, total=None, questions=None) -> None: # noqa: E501 + """GraphqlProblemsetQuestionList - a model defined in Swagger""" # noqa: E501 + self._total = None + self._questions = None + self.discriminator = None + if total is not None: + self.total = total + if questions is not None: + self.questions = questions + + @property + def total(self): + """Gets the total of this GraphqlProblemsetQuestionList. # noqa: E501 + + + :return: The total of this GraphqlProblemsetQuestionList. # noqa: E501 + :rtype: int + """ + return self._total + + @total.setter + def total(self, total): + """Sets the total of this GraphqlProblemsetQuestionList. + + + :param total: The total of this GraphqlProblemsetQuestionList. # noqa: E501 + :type: int + """ + + self._total = total + + @property + def questions(self): + """Gets the questions of this GraphqlProblemsetQuestionList. # noqa: E501 + + + :return: The questions of this GraphqlProblemsetQuestionList. # noqa: E501 + :rtype: list[GraphqlQuestionDetail] + """ + return self._questions + + @questions.setter + def questions(self, questions): + """Sets the questions of this GraphqlProblemsetQuestionList. + + + :param questions: The questions of this GraphqlProblemsetQuestionList. # noqa: E501 + :type: list[GraphqlQuestionDetail] + """ + + self._questions = questions + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) + else: + result[attr] = value + if issubclass(GraphqlProblemsetQuestionList, dict): + for key, value in self.items(): + result[key] = value + + return result + + def to_str(self) -> str: + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self) -> str: + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other: GraphqlProblemsetQuestionList) -> bool: + """Returns true if both objects are equal""" + if not isinstance(other, GraphqlProblemsetQuestionList): + return False + + return self.__dict__ == other.__dict__ + + def __ne__(self, other) -> bool: + """Returns true if both objects are not equal""" + return not self == other diff --git a/leetcode/models/graphql_query.py b/leetcode/models/graphql_query.py index 6d61ac1..c1b0fff 100644 --- a/leetcode/models/graphql_query.py +++ b/leetcode/models/graphql_query.py @@ -31,7 +31,7 @@ class GraphqlQuery(object): """ swagger_types = { "query": "str", - "variables": "GraphqlQueryVariables", + "variables": "AnyOfGraphqlQueryVariables", "operation_name": "str", } @@ -83,7 +83,7 @@ def variables(self): :return: The variables of this GraphqlQuery. # noqa: E501 - :rtype: GraphqlQueryVariables + :rtype: AnyOfGraphqlQueryVariables """ return self._variables @@ -93,7 +93,7 @@ def variables(self, variables): :param variables: The variables of this GraphqlQuery. # noqa: E501 - :type: GraphqlQueryVariables + :type: AnyOfGraphqlQueryVariables """ if variables is None: raise ValueError( diff --git a/leetcode/models/graphql_query_get_question_detail_variables.py b/leetcode/models/graphql_query_get_question_detail_variables.py new file mode 100644 index 0000000..015c4d7 --- /dev/null +++ b/leetcode/models/graphql_query_get_question_detail_variables.py @@ -0,0 +1,111 @@ +# coding: utf-8 + +""" + Leetcode API + + Leetcode API implementation. # noqa: E501 + + OpenAPI spec version: 1.0.1-1 + Contact: pv.safronov@gmail.com + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" +from __future__ import annotations + +import pprint +import re # noqa: F401 + +import six + + +class GraphqlQueryGetQuestionDetailVariables(object): + """NOTE: This class is auto generated by the swagger code generator program. + + Do not edit the class manually. + """ + + """ + Attributes: + swagger_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + swagger_types = {"title_slug": "str"} + + attribute_map = {"title_slug": "titleSlug"} + + def __init__(self, title_slug=None) -> None: # noqa: E501 + """GraphqlQueryGetQuestionDetailVariables - a model defined in Swagger""" # noqa: E501 + self._title_slug = None + self.discriminator = None + if title_slug is not None: + self.title_slug = title_slug + + @property + def title_slug(self): + """Gets the title_slug of this GraphqlQueryGetQuestionDetailVariables. # noqa: E501 + + + :return: The title_slug of this GraphqlQueryGetQuestionDetailVariables. # noqa: E501 + :rtype: str + """ + return self._title_slug + + @title_slug.setter + def title_slug(self, title_slug): + """Sets the title_slug of this GraphqlQueryGetQuestionDetailVariables. + + + :param title_slug: The title_slug of this GraphqlQueryGetQuestionDetailVariables. # noqa: E501 + :type: str + """ + + self._title_slug = title_slug + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) + else: + result[attr] = value + if issubclass(GraphqlQueryGetQuestionDetailVariables, dict): + for key, value in self.items(): + result[key] = value + + return result + + def to_str(self) -> str: + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self) -> str: + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other: GraphqlQueryGetQuestionDetailVariables) -> bool: + """Returns true if both objects are equal""" + if not isinstance(other, GraphqlQueryGetQuestionDetailVariables): + return False + + return self.__dict__ == other.__dict__ + + def __ne__(self, other) -> bool: + """Returns true if both objects are not equal""" + return not self == other diff --git a/leetcode/models/graphql_query_problemset_question_list_variables.py b/leetcode/models/graphql_query_problemset_question_list_variables.py new file mode 100644 index 0000000..fdd9358 --- /dev/null +++ b/leetcode/models/graphql_query_problemset_question_list_variables.py @@ -0,0 +1,195 @@ +# coding: utf-8 + +""" + Leetcode API + + Leetcode API implementation. # noqa: E501 + + OpenAPI spec version: 1.0.1-1 + Contact: pv.safronov@gmail.com + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" +from __future__ import annotations + +import pprint +import re # noqa: F401 + +import six + + +class GraphqlQueryProblemsetQuestionListVariables(object): + """NOTE: This class is auto generated by the swagger code generator program. + + Do not edit the class manually. + """ + + """ + Attributes: + swagger_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + swagger_types = { + "category_slug": "str", + "limit": "int", + "skip": "int", + "filters": "GraphqlQueryProblemsetQuestionListVariablesFilterInput", + } + + attribute_map = { + "category_slug": "categorySlug", + "limit": "limit", + "skip": "skip", + "filters": "filters", + } + + def __init__( + self, category_slug=None, limit=None, skip=None, filters=None + ) -> None: # noqa: E501 + """GraphqlQueryProblemsetQuestionListVariables - a model defined in Swagger""" # noqa: E501 + self._category_slug = None + self._limit = None + self._skip = None + self._filters = None + self.discriminator = None + if category_slug is not None: + self.category_slug = category_slug + if limit is not None: + self.limit = limit + if skip is not None: + self.skip = skip + if filters is not None: + self.filters = filters + + @property + def category_slug(self): + """Gets the category_slug of this GraphqlQueryProblemsetQuestionListVariables. # noqa: E501 + + + :return: The category_slug of this GraphqlQueryProblemsetQuestionListVariables. # noqa: E501 + :rtype: str + """ + return self._category_slug + + @category_slug.setter + def category_slug(self, category_slug): + """Sets the category_slug of this GraphqlQueryProblemsetQuestionListVariables. + + + :param category_slug: The category_slug of this GraphqlQueryProblemsetQuestionListVariables. # noqa: E501 + :type: str + """ + + self._category_slug = category_slug + + @property + def limit(self): + """Gets the limit of this GraphqlQueryProblemsetQuestionListVariables. # noqa: E501 + + + :return: The limit of this GraphqlQueryProblemsetQuestionListVariables. # noqa: E501 + :rtype: int + """ + return self._limit + + @limit.setter + def limit(self, limit): + """Sets the limit of this GraphqlQueryProblemsetQuestionListVariables. + + + :param limit: The limit of this GraphqlQueryProblemsetQuestionListVariables. # noqa: E501 + :type: int + """ + + self._limit = limit + + @property + def skip(self): + """Gets the skip of this GraphqlQueryProblemsetQuestionListVariables. # noqa: E501 + + + :return: The skip of this GraphqlQueryProblemsetQuestionListVariables. # noqa: E501 + :rtype: int + """ + return self._skip + + @skip.setter + def skip(self, skip): + """Sets the skip of this GraphqlQueryProblemsetQuestionListVariables. + + + :param skip: The skip of this GraphqlQueryProblemsetQuestionListVariables. # noqa: E501 + :type: int + """ + + self._skip = skip + + @property + def filters(self): + """Gets the filters of this GraphqlQueryProblemsetQuestionListVariables. # noqa: E501 + + + :return: The filters of this GraphqlQueryProblemsetQuestionListVariables. # noqa: E501 + :rtype: GraphqlQueryProblemsetQuestionListVariablesFilterInput + """ + return self._filters + + @filters.setter + def filters(self, filters): + """Sets the filters of this GraphqlQueryProblemsetQuestionListVariables. + + + :param filters: The filters of this GraphqlQueryProblemsetQuestionListVariables. # noqa: E501 + :type: GraphqlQueryProblemsetQuestionListVariablesFilterInput + """ + + self._filters = filters + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) + else: + result[attr] = value + if issubclass(GraphqlQueryProblemsetQuestionListVariables, dict): + for key, value in self.items(): + result[key] = value + + return result + + def to_str(self) -> str: + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self) -> str: + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other: GraphqlQueryProblemsetQuestionListVariables) -> bool: + """Returns true if both objects are equal""" + if not isinstance(other, GraphqlQueryProblemsetQuestionListVariables): + return False + + return self.__dict__ == other.__dict__ + + def __ne__(self, other) -> bool: + """Returns true if both objects are not equal""" + return not self == other diff --git a/leetcode/models/graphql_query_problemset_question_list_variables_filter_input.py b/leetcode/models/graphql_query_problemset_question_list_variables_filter_input.py new file mode 100644 index 0000000..9394bc8 --- /dev/null +++ b/leetcode/models/graphql_query_problemset_question_list_variables_filter_input.py @@ -0,0 +1,225 @@ +# coding: utf-8 + +""" + Leetcode API + + Leetcode API implementation. # noqa: E501 + + OpenAPI spec version: 1.0.1-1 + Contact: pv.safronov@gmail.com + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" +from __future__ import annotations + +import pprint +import re # noqa: F401 + +import six + + +class GraphqlQueryProblemsetQuestionListVariablesFilterInput(object): + """NOTE: This class is auto generated by the swagger code generator program. + + Do not edit the class manually. + """ + + """ + Attributes: + swagger_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + swagger_types = { + "tags": "list[str]", + "difficulty": "str", + "status": "str", + "list_id": "str", + "premium_only": "bool", + } + + attribute_map = { + "tags": "tags", + "difficulty": "difficulty", + "status": "status", + "list_id": "listId", + "premium_only": "premiumOnly", + } + + def __init__( + self, tags=None, difficulty=None, status=None, list_id=None, premium_only=None + ) -> None: # noqa: E501 + """GraphqlQueryProblemsetQuestionListVariablesFilterInput - a model defined in Swagger""" # noqa: E501 + self._tags = None + self._difficulty = None + self._status = None + self._list_id = None + self._premium_only = None + self.discriminator = None + if tags is not None: + self.tags = tags + if difficulty is not None: + self.difficulty = difficulty + if status is not None: + self.status = status + if list_id is not None: + self.list_id = list_id + if premium_only is not None: + self.premium_only = premium_only + + @property + def tags(self): + """Gets the tags of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. # noqa: E501 + + + :return: The tags of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. # noqa: E501 + :rtype: list[str] + """ + return self._tags + + @tags.setter + def tags(self, tags): + """Sets the tags of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. + + + :param tags: The tags of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. # noqa: E501 + :type: list[str] + """ + + self._tags = tags + + @property + def difficulty(self): + """Gets the difficulty of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. # noqa: E501 + + + :return: The difficulty of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. # noqa: E501 + :rtype: str + """ + return self._difficulty + + @difficulty.setter + def difficulty(self, difficulty): + """Sets the difficulty of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. + + + :param difficulty: The difficulty of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. # noqa: E501 + :type: str + """ + + self._difficulty = difficulty + + @property + def status(self): + """Gets the status of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. # noqa: E501 + + + :return: The status of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. # noqa: E501 + :rtype: str + """ + return self._status + + @status.setter + def status(self, status): + """Sets the status of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. + + + :param status: The status of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. # noqa: E501 + :type: str + """ + + self._status = status + + @property + def list_id(self): + """Gets the list_id of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. # noqa: E501 + + + :return: The list_id of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. # noqa: E501 + :rtype: str + """ + return self._list_id + + @list_id.setter + def list_id(self, list_id): + """Sets the list_id of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. + + + :param list_id: The list_id of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. # noqa: E501 + :type: str + """ + + self._list_id = list_id + + @property + def premium_only(self): + """Gets the premium_only of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. # noqa: E501 + + + :return: The premium_only of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. # noqa: E501 + :rtype: bool + """ + return self._premium_only + + @premium_only.setter + def premium_only(self, premium_only): + """Sets the premium_only of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. + + + :param premium_only: The premium_only of this GraphqlQueryProblemsetQuestionListVariablesFilterInput. # noqa: E501 + :type: bool + """ + + self._premium_only = premium_only + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) + else: + result[attr] = value + if issubclass(GraphqlQueryProblemsetQuestionListVariablesFilterInput, dict): + for key, value in self.items(): + result[key] = value + + return result + + def to_str(self) -> str: + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self) -> str: + """For `print` and `pprint`""" + return self.to_str() + + def __eq__( + self, other: GraphqlQueryProblemsetQuestionListVariablesFilterInput + ) -> bool: + """Returns true if both objects are equal""" + if not isinstance( + other, GraphqlQueryProblemsetQuestionListVariablesFilterInput + ): + return False + + return self.__dict__ == other.__dict__ + + def __ne__(self, other) -> bool: + """Returns true if both objects are not equal""" + return not self == other diff --git a/leetcode/models/graphql_query_variables.py b/leetcode/models/graphql_query_variables.py index 71ebcf5..7c61a37 100644 --- a/leetcode/models/graphql_query_variables.py +++ b/leetcode/models/graphql_query_variables.py @@ -29,37 +29,13 @@ class GraphqlQueryVariables(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - swagger_types = {"title_slug": "str"} + swagger_types = {} - attribute_map = {"title_slug": "titleSlug"} + attribute_map = {} - def __init__(self, title_slug=None): # noqa: E501 + def __init__(self): # noqa: E501 """GraphqlQueryVariables - a model defined in Swagger""" # noqa: E501 - self._title_slug = None self.discriminator = None - if title_slug is not None: - self.title_slug = title_slug - - @property - def title_slug(self): - """Gets the title_slug of this GraphqlQueryVariables. # noqa: E501 - - - :return: The title_slug of this GraphqlQueryVariables. # noqa: E501 - :rtype: str - """ - return self._title_slug - - @title_slug.setter - def title_slug(self, title_slug): - """Sets the title_slug of this GraphqlQueryVariables. - - - :param title_slug: The title_slug of this GraphqlQueryVariables. # noqa: E501 - :type: str - """ - - self._title_slug = title_slug def to_dict(self): """Returns the model properties as a dict""" diff --git a/leetcode/models/graphql_question_solution.py b/leetcode/models/graphql_question_solution.py index 56d9f53..c8089a5 100644 --- a/leetcode/models/graphql_question_solution.py +++ b/leetcode/models/graphql_question_solution.py @@ -38,7 +38,9 @@ class GraphqlQuestionSolution(object): "typename": "__typename", } - def __init__(self, id=None, can_see_detail=None, typename=None) -> None: # noqa: E501 + def __init__( + self, id=None, can_see_detail=None, typename=None + ) -> None: # noqa: E501 """GraphqlQuestionSolution - a model defined in Swagger""" # noqa: E501 self._id = None self._can_see_detail = None diff --git a/leetcode/models/graphql_user.py b/leetcode/models/graphql_user.py index 0c98fd3..6bd0173 100644 --- a/leetcode/models/graphql_user.py +++ b/leetcode/models/graphql_user.py @@ -37,7 +37,9 @@ class GraphqlUser(object): "is_current_user_premium": "isCurrentUserPremium", } - def __init__(self, username=None, is_current_user_premium=None) -> None: # noqa: E501 + def __init__( + self, username=None, is_current_user_premium=None + ) -> None: # noqa: E501 """GraphqlUser - a model defined in Swagger""" # noqa: E501 self._username = None self._is_current_user_premium = None diff --git a/setup.py b/setup.py index a57af48..79bf053 100644 --- a/setup.py +++ b/setup.py @@ -10,10 +10,11 @@ Generated by: https://github.com/swagger-api/swagger-codegen.git """ from __future__ import annotations + from setuptools import find_packages, setup # noqa: H301 NAME = "python-leetcode" -VERSION = "1.0.10" +VERSION = "1.1.0" with open("README.md") as readme: DESCRIPTION: str = readme.read() diff --git a/test/test_any_of_graphql_query_variables.py b/test/test_any_of_graphql_query_variables.py new file mode 100644 index 0000000..afcd76e --- /dev/null +++ b/test/test_any_of_graphql_query_variables.py @@ -0,0 +1,41 @@ +# coding: utf-8 + +""" + Leetcode API + + Leetcode API implementation. # noqa: E501 + + OpenAPI spec version: 1.0.1-1 + Contact: pv.safronov@gmail.com + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + +from __future__ import absolute_import, annotations + +import unittest + +import leetcode +from leetcode.models.any_of_graphql_query_variables import ( # noqa: E501 + AnyOfGraphqlQueryVariables, +) +from leetcode.rest import ApiException + + +class TestAnyOfGraphqlQueryVariables(unittest.TestCase): + """AnyOfGraphqlQueryVariables unit test stubs""" + + def setUp(self) -> None: + pass + + def tearDown(self) -> None: + pass + + def testAnyOfGraphqlQueryVariables(self) -> None: + """Test AnyOfGraphqlQueryVariables""" + # FIXME: construct object with mandatory attributes with example values + # model = leetcode.models.any_of_graphql_query_variables.AnyOfGraphqlQueryVariables() # noqa: E501 + pass + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_any_of_graphql_question_detail_solution.py b/test/test_any_of_graphql_question_detail_solution.py index 2b0f0c9..1c6952d 100644 --- a/test/test_any_of_graphql_question_detail_solution.py +++ b/test/test_any_of_graphql_question_detail_solution.py @@ -10,7 +10,7 @@ Generated by: https://github.com/swagger-api/swagger-codegen.git """ -from __future__ import annotations, absolute_import +from __future__ import absolute_import, annotations import unittest diff --git a/test/test_graphql_data.py b/test/test_graphql_data.py index 35c4ac5..d1dfb3a 100644 --- a/test/test_graphql_data.py +++ b/test/test_graphql_data.py @@ -10,7 +10,7 @@ Generated by: https://github.com/swagger-api/swagger-codegen.git """ -from __future__ import annotations, absolute_import +from __future__ import absolute_import, annotations import unittest diff --git a/test/test_graphql_problemset_question_list.py b/test/test_graphql_problemset_question_list.py new file mode 100644 index 0000000..ebb882f --- /dev/null +++ b/test/test_graphql_problemset_question_list.py @@ -0,0 +1,41 @@ +# coding: utf-8 + +""" + Leetcode API + + Leetcode API implementation. # noqa: E501 + + OpenAPI spec version: 1.0.1-1 + Contact: pv.safronov@gmail.com + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + +from __future__ import absolute_import, annotations + +import unittest + +import leetcode +from leetcode.models.graphql_problemset_question_list import ( # noqa: E501 + GraphqlProblemsetQuestionList, +) +from leetcode.rest import ApiException + + +class TestGraphqlProblemsetQuestionList(unittest.TestCase): + """GraphqlProblemsetQuestionList unit test stubs""" + + def setUp(self) -> None: + pass + + def tearDown(self) -> None: + pass + + def testGraphqlProblemsetQuestionList(self) -> None: + """Test GraphqlProblemsetQuestionList""" + # FIXME: construct object with mandatory attributes with example values + # model = leetcode.models.graphql_problemset_question_list.GraphqlProblemsetQuestionList() # noqa: E501 + pass + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_graphql_query_get_question_detail_variables.py b/test/test_graphql_query_get_question_detail_variables.py new file mode 100644 index 0000000..710e8d5 --- /dev/null +++ b/test/test_graphql_query_get_question_detail_variables.py @@ -0,0 +1,41 @@ +# coding: utf-8 + +""" + Leetcode API + + Leetcode API implementation. # noqa: E501 + + OpenAPI spec version: 1.0.1-1 + Contact: pv.safronov@gmail.com + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + +from __future__ import absolute_import, annotations + +import unittest + +import leetcode +from leetcode.models.graphql_query_get_question_detail_variables import ( # noqa: E501 + GraphqlQueryGetQuestionDetailVariables, +) +from leetcode.rest import ApiException + + +class TestGraphqlQueryGetQuestionDetailVariables(unittest.TestCase): + """GraphqlQueryGetQuestionDetailVariables unit test stubs""" + + def setUp(self) -> None: + pass + + def tearDown(self) -> None: + pass + + def testGraphqlQueryGetQuestionDetailVariables(self) -> None: + """Test GraphqlQueryGetQuestionDetailVariables""" + # FIXME: construct object with mandatory attributes with example values + # model = leetcode.models.graphql_query_get_question_detail_variables.GraphqlQueryGetQuestionDetailVariables() # noqa: E501 + pass + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_graphql_query_problemset_question_list_variables.py b/test/test_graphql_query_problemset_question_list_variables.py new file mode 100644 index 0000000..c99f4e9 --- /dev/null +++ b/test/test_graphql_query_problemset_question_list_variables.py @@ -0,0 +1,41 @@ +# coding: utf-8 + +""" + Leetcode API + + Leetcode API implementation. # noqa: E501 + + OpenAPI spec version: 1.0.1-1 + Contact: pv.safronov@gmail.com + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + +from __future__ import absolute_import, annotations + +import unittest + +import leetcode +from leetcode.models.graphql_query_problemset_question_list_variables import ( # noqa: E501 + GraphqlQueryProblemsetQuestionListVariables, +) +from leetcode.rest import ApiException + + +class TestGraphqlQueryProblemsetQuestionListVariables(unittest.TestCase): + """GraphqlQueryProblemsetQuestionListVariables unit test stubs""" + + def setUp(self) -> None: + pass + + def tearDown(self) -> None: + pass + + def testGraphqlQueryProblemsetQuestionListVariables(self) -> None: + """Test GraphqlQueryProblemsetQuestionListVariables""" + # FIXME: construct object with mandatory attributes with example values + # model = leetcode.models.graphql_query_problemset_question_list_variables.GraphqlQueryProblemsetQuestionListVariables() # noqa: E501 + pass + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_graphql_query_problemset_question_list_variables_filter_input.py b/test/test_graphql_query_problemset_question_list_variables_filter_input.py new file mode 100644 index 0000000..40440f3 --- /dev/null +++ b/test/test_graphql_query_problemset_question_list_variables_filter_input.py @@ -0,0 +1,41 @@ +# coding: utf-8 + +""" + Leetcode API + + Leetcode API implementation. # noqa: E501 + + OpenAPI spec version: 1.0.1-1 + Contact: pv.safronov@gmail.com + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + +from __future__ import absolute_import, annotations + +import unittest + +import leetcode +from leetcode.models.graphql_query_problemset_question_list_variables_filter_input import ( # noqa: E501 + GraphqlQueryProblemsetQuestionListVariablesFilterInput, +) +from leetcode.rest import ApiException + + +class TestGraphqlQueryProblemsetQuestionListVariablesFilterInput(unittest.TestCase): + """GraphqlQueryProblemsetQuestionListVariablesFilterInput unit test stubs""" + + def setUp(self) -> None: + pass + + def tearDown(self) -> None: + pass + + def testGraphqlQueryProblemsetQuestionListVariablesFilterInput(self) -> None: + """Test GraphqlQueryProblemsetQuestionListVariablesFilterInput""" + # FIXME: construct object with mandatory attributes with example values + # model = leetcode.models.graphql_query_problemset_question_list_variables_filter_input.GraphqlQueryProblemsetQuestionListVariablesFilterInput() # noqa: E501 + pass + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_graphql_question_code_snippet.py b/test/test_graphql_question_code_snippet.py index 71638c5..5116b4b 100644 --- a/test/test_graphql_question_code_snippet.py +++ b/test/test_graphql_question_code_snippet.py @@ -10,7 +10,7 @@ Generated by: https://github.com/swagger-api/swagger-codegen.git """ -from __future__ import annotations, absolute_import +from __future__ import absolute_import, annotations import unittest diff --git a/test/test_graphql_question_contributor.py b/test/test_graphql_question_contributor.py index 5b2e60a..4b0843e 100644 --- a/test/test_graphql_question_contributor.py +++ b/test/test_graphql_question_contributor.py @@ -10,7 +10,7 @@ Generated by: https://github.com/swagger-api/swagger-codegen.git """ -from __future__ import annotations, absolute_import +from __future__ import absolute_import, annotations import unittest diff --git a/test/test_graphql_question_solution.py b/test/test_graphql_question_solution.py index 5667853..6262508 100644 --- a/test/test_graphql_question_solution.py +++ b/test/test_graphql_question_solution.py @@ -10,7 +10,7 @@ Generated by: https://github.com/swagger-api/swagger-codegen.git """ -from __future__ import annotations, absolute_import +from __future__ import absolute_import, annotations import unittest diff --git a/test/test_graphql_question_topic_tag.py b/test/test_graphql_question_topic_tag.py index 9884de0..125e2d3 100644 --- a/test/test_graphql_question_topic_tag.py +++ b/test/test_graphql_question_topic_tag.py @@ -10,7 +10,7 @@ Generated by: https://github.com/swagger-api/swagger-codegen.git """ -from __future__ import annotations, absolute_import +from __future__ import absolute_import, annotations import unittest diff --git a/test/test_graphql_request_get_question_detail.py b/test/test_graphql_request_get_question_detail.py index 2c0991e..088893e 100644 --- a/test/test_graphql_request_get_question_detail.py +++ b/test/test_graphql_request_get_question_detail.py @@ -2,7 +2,9 @@ import test.base from leetcode.models.graphql_query import GraphqlQuery -from leetcode.models.graphql_query_variables import GraphqlQueryVariables +from leetcode.models.graphql_query_get_question_detail_variables import ( + GraphqlQueryGetQuestionDetailVariables, +) from leetcode.models.graphql_question_code_snippet import GraphqlQuestionCodeSnippet from leetcode.models.graphql_question_topic_tag import GraphqlQuestionTopicTag @@ -73,7 +75,7 @@ def test_request(self) -> None: } } """, - variables=GraphqlQueryVariables(title_slug="two-sum"), + variables=GraphqlQueryGetQuestionDetailVariables(title_slug="two-sum"), operation_name="getQuestionDetail", ) @@ -83,6 +85,10 @@ def test_request(self) -> None: assert data + problemset_question_list = data.problemset_question_list + + assert problemset_question_list is None + question = data.question user = data.user diff --git a/test/test_graphql_request_problemset_question_list.py b/test/test_graphql_request_problemset_question_list.py new file mode 100644 index 0000000..86ef410 --- /dev/null +++ b/test/test_graphql_request_problemset_question_list.py @@ -0,0 +1,210 @@ +import json +import test.base + +from leetcode.models.graphql_query import GraphqlQuery +from leetcode.models.graphql_query_problemset_question_list_variables import ( + GraphqlQueryProblemsetQuestionListVariables, +) +from leetcode.models.graphql_query_problemset_question_list_variables_filter_input import ( + GraphqlQueryProblemsetQuestionListVariablesFilterInput, +) +from leetcode.models.graphql_question_code_snippet import GraphqlQuestionCodeSnippet +from leetcode.models.graphql_question_topic_tag import GraphqlQuestionTopicTag + + +class TestGraphqlGetQuestionDetail(test.base.BaseTest): + def test_request(self) -> None: + graphql_request = GraphqlQuery( + query=""" + query problemsetQuestionList($categorySlug: String, $limit: Int, $skip: Int, $filters: QuestionListFilterInput) { + problemsetQuestionList: questionList( + categorySlug: $categorySlug + limit: $limit + skip: $skip + filters: $filters + ) { + total: totalNum + questions: data { + questionId + questionFrontendId + boundTopicId + title + frequency + freqBar + content + translatedTitle + isPaidOnly + difficulty + likes + dislikes + isLiked + isFavor + similarQuestions + contributors { + username + profileUrl + avatarUrl + __typename + } + langToValidPlayground + topicTags { + name + slug + translatedName + __typename + } + companyTagStats + codeSnippets { + lang + langSlug + code + __typename + } + stats + acRate + codeDefinition + hints + solution { + id + canSeeDetail + __typename + } + hasSolution + hasVideoSolution + status + sampleTestCase + enableRunCode + metaData + translatedContent + judgerAvailable + judgeType + mysqlSchemas + enableTestMode + envInfo + __typename + } + } + } + """, + variables=GraphqlQueryProblemsetQuestionListVariables( + category_slug="algorithms", + limit=1, + skip=2, + filters=GraphqlQueryProblemsetQuestionListVariablesFilterInput( + tags=["array"], + difficulty="MEDIUM", + status="NOT_STARTED", + list_id="7p5x763", # Top Amazon Questions + premium_only=False, + ), + ), + operation_name="problemsetQuestionList", + ) + + response = self._api_instance.graphql_post(body=graphql_request) + + data = response.data + + question = data.question + + assert question is None + + assert data + + assert data.problemset_question_list.total > 0 + + question_list = data.problemset_question_list.questions + user = data.user + + question = question_list[0] + + assert user is None + + assert question.question_id is not None + assert question.question_frontend_id is not None + assert question.bound_topic_id is None + assert question.title is not None + assert question.frequency == 0.0 + assert question.freq_bar > 0 + assert len(question.content) > 10 + assert question.translated_title is None + assert question.is_paid_only in (True, False) + assert question.difficulty == "Medium" + assert question.likes > 0 + assert question.dislikes > 0 + assert question.is_liked is None + assert question.is_favor in (True, False) + + json.loads(question.similar_questions) + + assert len(question.contributors) == 0 + assert "python" in list(json.loads(question.lang_to_valid_playground).keys()) + topic_tag = question.topic_tags[0] + assert isinstance(topic_tag, GraphqlQuestionTopicTag) + assert len(topic_tag.name) > 0 + assert len(topic_tag.slug) > 0 + assert question.topic_tags[0].translated_name is None + assert len(topic_tag.typename) > 0 + + tag_stat = list(json.loads(question.company_tag_stats).values())[0][0] + + assert tag_stat["taggedByAdmin"] in (True, False) + assert len(tag_stat["name"]) > 0 + assert len(tag_stat["slug"]) > 0 + assert tag_stat["timesEncountered"] > 0 + + code_snippet = question.code_snippets[0] + + assert isinstance(code_snippet, GraphqlQuestionCodeSnippet) + assert len(code_snippet.code) > 0 + assert len(code_snippet.lang) > 0 + assert len(code_snippet.lang_slug) > 0 + assert code_snippet.typename == "CodeSnippetNode" + + stats = json.loads(question.stats) + + assert len(stats["totalAccepted"]) > 0 + assert len(stats["totalSubmission"]) > 0 + assert int(stats["totalAcceptedRaw"]) > 0 + assert int(stats["totalSubmissionRaw"]) > 0 + + assert question.ac_rate > 0 + + code_definition = json.loads(question.code_definition)[0] + + assert len(code_definition["value"]) > 0 + assert len(code_definition["text"]) > 0 + assert len(code_definition["defaultCode"]) > 0 + + assert [len(hint) > 0 for hint in question.hints] + + question.solution + + assert question.has_solution in (True, False) + assert question.has_video_solution in (True, False) + + assert question.status in ("ac", "not_started", "tried", None) + + assert len(question.sample_test_case) > 0 + + assert question.enable_run_code in (True, False) + + meta_data = json.loads(question.meta_data) + + assert meta_data["name"] is not None + assert meta_data["params"][0]["name"] + assert meta_data["params"][0]["type"] + assert meta_data["return"]["type"] + + assert question.translated_content is None + + assert question.judger_available is True + assert question.judge_type in ("large", "small") + + assert question.mysql_schemas == [] + + assert question.enable_test_mode in (True, False) + + env_info = json.loads(question.env_info) + + assert env_info["cpp"][0] == "C++" diff --git a/test/test_graphql_request_user.py b/test/test_graphql_request_user.py index 0d19102..8ddbc8f 100644 --- a/test/test_graphql_request_user.py +++ b/test/test_graphql_request_user.py @@ -1,7 +1,7 @@ import json import test.base -import leetcode +import leetcode.models.graphql_query_variables class TestGraphqlGetUser(test.base.BaseTest): @@ -15,7 +15,7 @@ def test_request(self) -> None: } } """, - variables=leetcode.GraphqlQueryVariables(), + variables=leetcode.models.graphql_query_variables.GraphqlQueryVariables(), operation_name="", ) diff --git a/test/test_graphql_user.py b/test/test_graphql_user.py index 9e07da2..856a5c1 100644 --- a/test/test_graphql_user.py +++ b/test/test_graphql_user.py @@ -10,7 +10,7 @@ Generated by: https://github.com/swagger-api/swagger-codegen.git """ -from __future__ import annotations, absolute_import +from __future__ import absolute_import, annotations import unittest From 7fdb28d17f731e67a53909292dfdb6cf35f7f5ed Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Tue, 26 Oct 2021 17:31:49 +0100 Subject: [PATCH 10/24] Added titleSlug field to question details and fixed totalNum field name of problemset list reponse --- docs/GraphqlProblemsetQuestionList.md | 2 +- docs/GraphqlQuestionDetail.md | 1 + .../graphql_problemset_question_list.py | 30 +++++++++---------- leetcode/models/graphql_question_detail.py | 27 +++++++++++++++++ setup.py | 2 +- ...est_graphql_request_get_question_detail.py | 2 ++ ...raphql_request_problemset_question_list.py | 4 +-- 7 files changed, 49 insertions(+), 19 deletions(-) diff --git a/docs/GraphqlProblemsetQuestionList.md b/docs/GraphqlProblemsetQuestionList.md index 5253478..3bd62e0 100644 --- a/docs/GraphqlProblemsetQuestionList.md +++ b/docs/GraphqlProblemsetQuestionList.md @@ -3,7 +3,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**total** | **int** | | [optional] +**total_num** | **int** | | [optional] **questions** | [**list[GraphqlQuestionDetail]**](GraphqlQuestionDetail.md) | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/GraphqlQuestionDetail.md b/docs/GraphqlQuestionDetail.md index c91d96f..e97b286 100644 --- a/docs/GraphqlQuestionDetail.md +++ b/docs/GraphqlQuestionDetail.md @@ -7,6 +7,7 @@ Name | Type | Description | Notes **question_frontend_id** | **str** | | [optional] **bound_topic_id** | **str** | | [optional] **title** | **str** | | [optional] +**title_slug** | **str** | | [optional] **frequency** | **float** | | [optional] **freq_bar** | **float** | | [optional] **content** | **str** | | [optional] diff --git a/leetcode/models/graphql_problemset_question_list.py b/leetcode/models/graphql_problemset_question_list.py index 890b1e1..b0f1e11 100644 --- a/leetcode/models/graphql_problemset_question_list.py +++ b/leetcode/models/graphql_problemset_question_list.py @@ -30,40 +30,40 @@ class GraphqlProblemsetQuestionList(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - swagger_types = {"total": "int", "questions": "list[GraphqlQuestionDetail]"} + swagger_types = {"total_num": "int", "questions": "list[GraphqlQuestionDetail]"} - attribute_map = {"total": "total", "questions": "questions"} + attribute_map = {"total_num": "totalNum", "questions": "questions"} - def __init__(self, total=None, questions=None) -> None: # noqa: E501 + def __init__(self, total_num=None, questions=None) -> None: # noqa: E501 """GraphqlProblemsetQuestionList - a model defined in Swagger""" # noqa: E501 - self._total = None + self._total_num = None self._questions = None self.discriminator = None - if total is not None: - self.total = total + if total_num is not None: + self.total_num = total_num if questions is not None: self.questions = questions @property - def total(self): - """Gets the total of this GraphqlProblemsetQuestionList. # noqa: E501 + def total_num(self): + """Gets the total_num of this GraphqlProblemsetQuestionList. # noqa: E501 - :return: The total of this GraphqlProblemsetQuestionList. # noqa: E501 + :return: The total_num of this GraphqlProblemsetQuestionList. # noqa: E501 :rtype: int """ - return self._total + return self._total_num - @total.setter - def total(self, total): - """Sets the total of this GraphqlProblemsetQuestionList. + @total_num.setter + def total_num(self, total_num): + """Sets the total_num of this GraphqlProblemsetQuestionList. - :param total: The total of this GraphqlProblemsetQuestionList. # noqa: E501 + :param total_num: The total_num of this GraphqlProblemsetQuestionList. # noqa: E501 :type: int """ - self._total = total + self._total_num = total_num @property def questions(self): diff --git a/leetcode/models/graphql_question_detail.py b/leetcode/models/graphql_question_detail.py index 215b67d..9fdb0fd 100644 --- a/leetcode/models/graphql_question_detail.py +++ b/leetcode/models/graphql_question_detail.py @@ -34,6 +34,7 @@ class GraphqlQuestionDetail(object): "question_frontend_id": "str", "bound_topic_id": "str", "title": "str", + "title_slug": "str", "frequency": "float", "freq_bar": "float", "content": "str", @@ -74,6 +75,7 @@ class GraphqlQuestionDetail(object): "question_frontend_id": "questionFrontendId", "bound_topic_id": "boundTopicId", "title": "title", + "title_slug": "titleSlug", "frequency": "frequency", "freq_bar": "freqBar", "content": "content", @@ -115,6 +117,7 @@ def __init__( question_frontend_id=None, bound_topic_id=None, title=None, + title_slug=None, frequency=None, freq_bar=None, content=None, @@ -154,6 +157,7 @@ def __init__( self._question_frontend_id = None self._bound_topic_id = None self._title = None + self._title_slug = None self._frequency = None self._freq_bar = None self._content = None @@ -196,6 +200,8 @@ def __init__( self.bound_topic_id = bound_topic_id if title is not None: self.title = title + if title_slug is not None: + self.title_slug = title_slug if frequency is not None: self.frequency = frequency if freq_bar is not None: @@ -347,6 +353,27 @@ def title(self, title): self._title = title + @property + def title_slug(self): + """Gets the title_slug of this GraphqlQuestionDetail. # noqa: E501 + + + :return: The title_slug of this GraphqlQuestionDetail. # noqa: E501 + :rtype: str + """ + return self._title_slug + + @title_slug.setter + def title_slug(self, title_slug): + """Sets the title_slug of this GraphqlQuestionDetail. + + + :param title_slug: The title_slug of this GraphqlQuestionDetail. # noqa: E501 + :type: str + """ + + self._title_slug = title_slug + @property def frequency(self): """Gets the frequency of this GraphqlQuestionDetail. # noqa: E501 diff --git a/setup.py b/setup.py index 79bf053..2810149 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ from setuptools import find_packages, setup # noqa: H301 NAME = "python-leetcode" -VERSION = "1.1.0" +VERSION = "1.2.0" with open("README.md") as readme: DESCRIPTION: str = readme.read() diff --git a/test/test_graphql_request_get_question_detail.py b/test/test_graphql_request_get_question_detail.py index 088893e..6e3fc83 100644 --- a/test/test_graphql_request_get_question_detail.py +++ b/test/test_graphql_request_get_question_detail.py @@ -19,6 +19,7 @@ def test_request(self) -> None: questionFrontendId boundTopicId title + titleSlug frequency freqBar content @@ -98,6 +99,7 @@ def test_request(self) -> None: assert question.question_frontend_id == "1" assert question.bound_topic_id is None assert question.title == "Two Sum" + assert question.title_slug == "two-sum" assert question.frequency == 0.0 assert question.freq_bar > 0 assert len(question.content) > 10 diff --git a/test/test_graphql_request_problemset_question_list.py b/test/test_graphql_request_problemset_question_list.py index 86ef410..c5801a4 100644 --- a/test/test_graphql_request_problemset_question_list.py +++ b/test/test_graphql_request_problemset_question_list.py @@ -23,7 +23,7 @@ def test_request(self) -> None: skip: $skip filters: $filters ) { - total: totalNum + totalNum questions: data { questionId questionFrontendId @@ -111,7 +111,7 @@ def test_request(self) -> None: assert data - assert data.problemset_question_list.total > 0 + assert data.problemset_question_list.total_num > 0 question_list = data.problemset_question_list.questions user = data.user From 1787fff62a1b6b1e191c7ae033d3f16856884bc6 Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Tue, 26 Oct 2021 21:10:40 +0100 Subject: [PATCH 11/24] Added category title field --- docs/GraphqlQuestionDetail.md | 1 + leetcode/models/graphql_question_detail.py | 27 ++++++++++++++++++++++ setup.py | 2 +- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/docs/GraphqlQuestionDetail.md b/docs/GraphqlQuestionDetail.md index e97b286..c02634f 100644 --- a/docs/GraphqlQuestionDetail.md +++ b/docs/GraphqlQuestionDetail.md @@ -8,6 +8,7 @@ Name | Type | Description | Notes **bound_topic_id** | **str** | | [optional] **title** | **str** | | [optional] **title_slug** | **str** | | [optional] +**category_title** | **str** | | [optional] **frequency** | **float** | | [optional] **freq_bar** | **float** | | [optional] **content** | **str** | | [optional] diff --git a/leetcode/models/graphql_question_detail.py b/leetcode/models/graphql_question_detail.py index 9fdb0fd..0d3498a 100644 --- a/leetcode/models/graphql_question_detail.py +++ b/leetcode/models/graphql_question_detail.py @@ -35,6 +35,7 @@ class GraphqlQuestionDetail(object): "bound_topic_id": "str", "title": "str", "title_slug": "str", + "category_title": "str", "frequency": "float", "freq_bar": "float", "content": "str", @@ -76,6 +77,7 @@ class GraphqlQuestionDetail(object): "bound_topic_id": "boundTopicId", "title": "title", "title_slug": "titleSlug", + "category_title": "categoryTitle", "frequency": "frequency", "freq_bar": "freqBar", "content": "content", @@ -118,6 +120,7 @@ def __init__( bound_topic_id=None, title=None, title_slug=None, + category_title=None, frequency=None, freq_bar=None, content=None, @@ -158,6 +161,7 @@ def __init__( self._bound_topic_id = None self._title = None self._title_slug = None + self._category_title = None self._frequency = None self._freq_bar = None self._content = None @@ -202,6 +206,8 @@ def __init__( self.title = title if title_slug is not None: self.title_slug = title_slug + if category_title is not None: + self.category_title = category_title if frequency is not None: self.frequency = frequency if freq_bar is not None: @@ -374,6 +380,27 @@ def title_slug(self, title_slug): self._title_slug = title_slug + @property + def category_title(self): + """Gets the category_title of this GraphqlQuestionDetail. # noqa: E501 + + + :return: The category_title of this GraphqlQuestionDetail. # noqa: E501 + :rtype: str + """ + return self._category_title + + @category_title.setter + def category_title(self, category_title): + """Sets the category_title of this GraphqlQuestionDetail. + + + :param category_title: The category_title of this GraphqlQuestionDetail. # noqa: E501 + :type: str + """ + + self._category_title = category_title + @property def frequency(self): """Gets the frequency of this GraphqlQuestionDetail. # noqa: E501 diff --git a/setup.py b/setup.py index 2810149..1323596 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ from setuptools import find_packages, setup # noqa: H301 NAME = "python-leetcode" -VERSION = "1.2.0" +VERSION = "1.2.1" with open("README.md") as readme: DESCRIPTION: str = readme.read() From 833d92bf04a8da9c21253aebb908ad8ca9fa785f Mon Sep 17 00:00:00 2001 From: dimaglushkov Date: Thu, 24 Feb 2022 13:58:48 +0300 Subject: [PATCH 12/24] #14 add requriements loading from requriements.txt --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 1323596..4b7b0c9 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,8 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["urllib3 >= 1.15", "six >= 1.10", "certifi", "python-dateutil", "requests"] +with open("requirements.txt") as requirements: + REQUIRES = [req.replace('\n', '') for req in requirements.readlines()] setup( name=NAME, From 08779329c90e63aa989fef56cca01b4a36ece9cc Mon Sep 17 00:00:00 2001 From: dimaglushkov Date: Thu, 24 Feb 2022 14:06:40 +0300 Subject: [PATCH 13/24] #17 fix argument type in example.py --- example.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example.py b/example.py index 8d38d7d..bb61f76 100644 --- a/example.py +++ b/example.py @@ -96,7 +96,7 @@ } } """, - variables=leetcode.GraphqlQueryVariables(title_slug="two-sum"), + variables=leetcode.GraphqlQueryGetQuestionDetailVariables(title_slug="two-sum"), operation_name="getQuestionDetail", ) From a4f29e6b0bfc2e774950d93da544490d9435a10b Mon Sep 17 00:00:00 2001 From: Dima Glushkov <38703979+dimaglushkov@users.noreply.github.com> Date: Sun, 6 Mar 2022 19:36:12 +0300 Subject: [PATCH 14/24] Update setup.py Co-authored-by: Pavel Safronov --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 4b7b0c9..ae727f1 100644 --- a/setup.py +++ b/setup.py @@ -27,7 +27,7 @@ # http://pypi.python.org/pypi/setuptools with open("requirements.txt") as requirements: - REQUIRES = [req.replace('\n', '') for req in requirements.readlines()] + REQUIRES = [req.replace("\n", "") for req in requirements.readlines()] setup( name=NAME, From 904b03c408b5b5cbec933de6d80d811d90b4626e Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Sun, 6 Mar 2022 17:28:30 +0000 Subject: [PATCH 15/24] Changed a test question to make tests work --- test/test_graphql_request_problemset_question_list.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_graphql_request_problemset_question_list.py b/test/test_graphql_request_problemset_question_list.py index c5801a4..3a79707 100644 --- a/test/test_graphql_request_problemset_question_list.py +++ b/test/test_graphql_request_problemset_question_list.py @@ -89,7 +89,7 @@ def test_request(self) -> None: variables=GraphqlQueryProblemsetQuestionListVariables( category_slug="algorithms", limit=1, - skip=2, + skip=3, filters=GraphqlQueryProblemsetQuestionListVariablesFilterInput( tags=["array"], difficulty="MEDIUM", From c86206a13f75b67b21e89df27080761513bfe194 Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Sun, 6 Mar 2022 17:31:11 +0000 Subject: [PATCH 16/24] Bump the version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index ae727f1..9ed8dc3 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ from setuptools import find_packages, setup # noqa: H301 NAME = "python-leetcode" -VERSION = "1.2.1" +VERSION = "1.2.2" with open("README.md") as readme: DESCRIPTION: str = readme.read() From a9c17c58d8a8a7f79ecd0bd4d1a7d851eaae876b Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Wed, 26 Feb 2025 22:24:04 +0000 Subject: [PATCH 17/24] remove csrf auth method, because it doesnt work --- .github/workflows/pytest.yml | 1 + README.md | 14 +++++--------- example.py | 4 +--- leetcode/auth.py | 12 ------------ setup.py | 2 +- test/base.py | 5 ++--- 6 files changed, 10 insertions(+), 28 deletions(-) delete mode 100644 leetcode/auth.py diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 477d11b..bda6762 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -23,3 +23,4 @@ jobs: run: pytest -vvvv -s env: LEETCODE_SESSION_ID: ${{ secrets.LEETCODE_SESSION }} + LEETCODE_CSRF_TOKEN: ${{ secrets.LEETCODE_CSRF_TOKEN}} diff --git a/README.md b/README.md index caaa3b7..3d90fcd 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -![build](https://github.com/prius/python-leetcode/actions/workflows/publish-to-pypi.yml/badge.svg) -![tests](https://github.com/prius/python-leetcode/actions/workflows/pytest.yml/badge.svg) +![build](https://github.com/fspv/python-leetcode/actions/workflows/publish-to-pypi.yml/badge.svg) +![tests](https://github.com/fspv/python-leetcode/actions/workflows/pytest.yml/badge.svg) ![pypi](https://badge.fury.io/py/python-leetcode.svg) ![pypi-downloads](https://img.shields.io/pypi/dm/python-leetcode) ![python-versions](https://img.shields.io/pypi/pyversions/python-leetcode) @@ -9,7 +9,7 @@ This repo contains a python client to access all known so far methods of Leetcode API. -The code is autogenerated by swagger. Swagger reference can be found here: [https://github.com/prius/leetcode-swagger](https://github.com/prius/leetcode-swagger) +The code is autogenerated by swagger. Swagger reference can be found here: [https://github.com/fspv/leetcode-swagger](https://github.com/fspv/leetcode-swagger) PyPi package link: [https://pypi.org/project/python-leetcode/](https://pypi.org/project/python-leetcode/) @@ -30,10 +30,6 @@ import leetcode leetcode_session = "yyy" csrf_token = "xxx" -# Experimental: Or CSRF token can be obtained automatically -import leetcode.auth -csrf_token = leetcode.auth.get_csrf_cookie(leetcode_session) - configuration = leetcode.Configuration() configuration.api_key["x-csrftoken"] = csrf_token @@ -168,8 +164,8 @@ In this case memoization topic is one of the targets for improvement, so I can g ## Example services using this library -* Anki cards generator [https://github.com/prius/leetcode-anki](https://github.com/prius/leetcode-anki) -* Leetcode helper website [https://github.com/prius/grind-helper](https://github.com/prius/grind-helper) +* Anki cards generator [https://github.com/fspv/leetcode-anki](https://github.com/fspv/leetcode-anki) +* Leetcode helper website [https://github.com/fspv/grind-helper](https://github.com/fspv/grind-helper) ## Additional info You can find other examples of usage in `example.py` diff --git a/example.py b/example.py index bb61f76..1fc29cb 100644 --- a/example.py +++ b/example.py @@ -1,11 +1,9 @@ from __future__ import annotations import os -import sys from time import sleep import leetcode -import leetcode.auth # Initialize client configuration = leetcode.Configuration() @@ -14,7 +12,7 @@ # fields which contain corresponding cookies from web browser leetcode_session: str = os.environ["LEETCODE_SESSION_ID"] -csrf_token: str = leetcode.auth.get_csrf_cookie(leetcode_session) +csrf_token = os.environ["LEETCODE_CSRF_TOKEN"] configuration.api_key["x-csrftoken"] = csrf_token configuration.api_key["csrftoken"] = csrf_token diff --git a/leetcode/auth.py b/leetcode/auth.py deleted file mode 100644 index d9efd68..0000000 --- a/leetcode/auth.py +++ /dev/null @@ -1,12 +0,0 @@ -import requests - - -def get_csrf_cookie(session_id: str) -> str: - response = requests.get( - "https://leetcode.com/", - cookies={ - "LEETCODE_SESSION": session_id, - }, - ) - - return response.cookies["csrftoken"] diff --git a/setup.py b/setup.py index 9ed8dc3..92a2c8a 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ from setuptools import find_packages, setup # noqa: H301 NAME = "python-leetcode" -VERSION = "1.2.2" +VERSION = "1.2.3" with open("README.md") as readme: DESCRIPTION: str = readme.read() diff --git a/test/base.py b/test/base.py index dca44f6..a6fa2a9 100644 --- a/test/base.py +++ b/test/base.py @@ -3,7 +3,6 @@ import leetcode.api.default_api import leetcode.api_client -import leetcode.auth import leetcode.configuration @@ -25,9 +24,9 @@ def _api_instance( ) -> None: self._api_instance_containter = value - def setup(self) -> None: + def setup_method(self) -> None: session_id = os.environ["LEETCODE_SESSION_ID"] - csrftoken = leetcode.auth.get_csrf_cookie(session_id) + csrftoken = os.environ["LEETCODE_CSRF_TOKEN"] configuration = leetcode.configuration.Configuration() From 000a8df6dd7596642a139521e9dfc46ce319c823 Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Wed, 26 Feb 2025 22:47:51 +0000 Subject: [PATCH 18/24] bump python version --- .github/workflows/publish-to-pypi.yml | 4 ++-- .github/workflows/pytest.yml | 4 ++-- setup.py | 8 ++++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index 09fcc54..9f649a7 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -7,10 +7,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@master - - name: Set up Python 3.9 + - name: Set up Python uses: actions/setup-python@v1 with: - python-version: 3.9 + python-version: 3.13 - name: Build a binary wheel and a source tarball run: python setup.py sdist - name: Publish distribution package to Test PyPI diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index bda6762..dbf95f2 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -7,10 +7,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@master - - name: Set up Python 3.9 + - name: Set up Python uses: actions/setup-python@v1 with: - python-version: 3.9 + python-version: 3.13 - name: Install requirements run: pip install -r requirements.txt - name: Install test requirements diff --git a/setup.py b/setup.py index 92a2c8a..1bc1fed 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ from setuptools import find_packages, setup # noqa: H301 NAME = "python-leetcode" -VERSION = "1.2.3" +VERSION = "1.2.4" with open("README.md") as readme: DESCRIPTION: str = readme.read() @@ -35,7 +35,7 @@ description="Leetcode API", author="Pavel Safronov", author_email="pv.safronov@gmail.com", - url="https://github.com/prius/python-leetcode", + url="https://github.com/fspv/python-leetcode", keywords=["leetcode", "faang", "interview", "api"], install_requires=REQUIRES, packages=find_packages(), @@ -50,6 +50,10 @@ "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", ], python_requires=">=3.8", ) From 54d72029fda49d5328cfdc8eeda0646501b4ed56 Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Wed, 26 Feb 2025 22:51:15 +0000 Subject: [PATCH 19/24] Try python 3.12 --- .github/workflows/publish-to-pypi.yml | 2 +- .github/workflows/pytest.yml | 2 +- setup.py | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index 9f649a7..e8f8d17 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -10,7 +10,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v1 with: - python-version: 3.13 + python-version: 3.12 - name: Build a binary wheel and a source tarball run: python setup.py sdist - name: Publish distribution package to Test PyPI diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index dbf95f2..1a161de 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -10,7 +10,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v1 with: - python-version: 3.13 + python-version: 3.12 - name: Install requirements run: pip install -r requirements.txt - name: Install test requirements diff --git a/setup.py b/setup.py index 1bc1fed..e88deb7 100644 --- a/setup.py +++ b/setup.py @@ -53,7 +53,6 @@ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: 3.13", ], python_requires=">=3.8", ) From d0ecdf6c829242005c0321545c12f53b32e38ee7 Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Wed, 26 Feb 2025 22:52:59 +0000 Subject: [PATCH 20/24] install requirements --- .github/workflows/publish-to-pypi.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index e8f8d17..b704c43 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -11,6 +11,8 @@ jobs: uses: actions/setup-python@v1 with: python-version: 3.12 + - name: Install requirements + run: pip install -r requirements.txt - name: Build a binary wheel and a source tarball run: python setup.py sdist - name: Publish distribution package to Test PyPI From 9d306b4e75fef7bc8746c20385ba4360048fd4a0 Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Wed, 26 Feb 2025 23:00:01 +0000 Subject: [PATCH 21/24] fix build --- git_push.sh | 2 +- setup.py | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/git_push.sh b/git_push.sh index 1410312..e31c23b 100644 --- a/git_push.sh +++ b/git_push.sh @@ -8,7 +8,7 @@ git_repo_id=$2 release_note=$3 if [ "$git_user_id" = "" ]; then - git_user_id="prius" + git_user_id="fspv" echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" fi diff --git a/setup.py b/setup.py index e88deb7..1c22946 100644 --- a/setup.py +++ b/setup.py @@ -26,9 +26,6 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -with open("requirements.txt") as requirements: - REQUIRES = [req.replace("\n", "") for req in requirements.readlines()] - setup( name=NAME, version=VERSION, @@ -37,7 +34,14 @@ author_email="pv.safronov@gmail.com", url="https://github.com/fspv/python-leetcode", keywords=["leetcode", "faang", "interview", "api"], - install_requires=REQUIRES, + install_requires=[ + "certifi >= 14.05.14", + "six >= 1.10", + "python_dateutil >= 2.5.3", + "setuptools >= 21.0.0", + "urllib3 >= 1.15.1", + "requests", + ], packages=find_packages(), include_package_data=True, long_description=DESCRIPTION, From 8b20a845cb883d08faeaed11d710196024949dd2 Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Wed, 26 Feb 2025 23:02:25 +0000 Subject: [PATCH 22/24] bump version + instructions --- README.md | 14 ++++++++++++++ setup.py | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3d90fcd..ca6ce6d 100644 --- a/README.md +++ b/README.md @@ -171,3 +171,17 @@ In this case memoization topic is one of the targets for improvement, so I can g You can find other examples of usage in `example.py` Autogenerated by swagger documentation can be found [here](/README.generated.md). + +## Development + +Test new created package before publishing +```sh +pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ python-leetcode==1.2.4 +``` + +Publish package +```sh +git tag 1.2.4 +git push --tags + +``` diff --git a/setup.py b/setup.py index 1c22946..55b7541 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ from setuptools import find_packages, setup # noqa: H301 NAME = "python-leetcode" -VERSION = "1.2.4" +VERSION = "1.2.5" with open("README.md") as readme: DESCRIPTION: str = readme.read() From e0e8463c564a92c1fe6489ba81969622536600fb Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Sat, 22 Mar 2025 19:11:40 +0000 Subject: [PATCH 23/24] add some tests --- test/base.py | 39 +++++- test/test_default_api.py | 117 +++++++++++++++--- test/test_difficulty.py | 6 +- ...est_graphql_request_get_question_detail.py | 16 +-- ...raphql_request_problemset_question_list.py | 18 +-- 5 files changed, 158 insertions(+), 38 deletions(-) diff --git a/test/base.py b/test/base.py index a6fa2a9..4e7689f 100644 --- a/test/base.py +++ b/test/base.py @@ -1,10 +1,47 @@ import os -from typing import Optional +from typing import Any, Optional import leetcode.api.default_api import leetcode.api_client import leetcode.configuration +def validate_stat_status_pair(stat_status_pair: Any) -> None: + assert isinstance(stat_status_pair, leetcode.StatStatusPair) + assert isinstance(stat_status_pair.difficulty, leetcode.Difficulty) + assert isinstance(stat_status_pair.difficulty.level, int) + assert isinstance(stat_status_pair.frequency, float) + assert isinstance(stat_status_pair.is_favor, bool) + assert isinstance(stat_status_pair.paid_only, bool) + assert isinstance(stat_status_pair.stat, leetcode.Stat) + if stat_status_pair.status is not None: + assert isinstance(stat_status_pair.status, str) + + assert isinstance(stat_status_pair.stat.frontend_question_id, int) + assert isinstance(stat_status_pair.stat.is_new_question, bool) + if stat_status_pair.stat.question__article__live is not None: + assert isinstance(stat_status_pair.stat.question__article__live, bool) + if stat_status_pair.stat.question__article__slug is not None: + assert isinstance(stat_status_pair.stat.question__article__slug, str) + assert isinstance(stat_status_pair.stat.question__hide, bool) + assert isinstance(stat_status_pair.stat.question__title, str) + assert isinstance(stat_status_pair.stat.question__title_slug, str) + assert isinstance(stat_status_pair.stat.question_id, int) + assert isinstance(stat_status_pair.stat.total_acs, int) + assert isinstance(stat_status_pair.stat.total_submitted, int) + +def validate_problems(problems: Any, category_slug: str) -> None: + assert isinstance(problems, leetcode.Problems) + assert isinstance(problems.ac_easy, int) + assert isinstance(problems.ac_hard, int) + assert isinstance(problems.ac_medium, int) + assert problems.category_slug == category_slug + assert isinstance(problems.num_solved, int) + assert isinstance(problems.num_total, int) + assert isinstance(problems.stat_status_pairs, list) + + for stat_status_pair in problems.stat_status_pairs: + validate_stat_status_pair(stat_status_pair) + class BaseTest: _api_instance_containter: Optional[leetcode.api.default_api.DefaultApi] = None diff --git a/test/test_default_api.py b/test/test_default_api.py index 91b85bb..49af474 100644 --- a/test/test_default_api.py +++ b/test/test_default_api.py @@ -12,41 +12,120 @@ from __future__ import absolute_import +from time import sleep import unittest +from leetcode.models.interpretation import Interpretation +from leetcode.models.submission_id import SubmissionId +import test.base import leetcode from leetcode.api.default_api import DefaultApi # noqa: E501 from leetcode.rest import ApiException -class TestDefaultApi(unittest.TestCase): - """DefaultApi unit test stubs""" - - def setUp(self): - self.api = DefaultApi() # noqa: E501 +class TestDefaultApi(test.base.BaseTest): + def test_api_problems_topic_get(self): + result = self._api_instance.api_problems_topic_get(topic="algorithms") + test.base.validate_problems(result, "algorithms") - def tearDown(self): - pass + result = self._api_instance.api_problems_topic_get(topic="nonexistent") + test.base.validate_problems(result, "nonexistent") - def test_api_problems_topic_get(self): - """Test case for api_problems_topic_get""" - pass + try: + self._api_instance.api_problems_topic_get(topic="") + assert False + except ApiException as e: + assert e.status == 404 def test_graphql_post(self): - """Test case for graphql_post""" pass def test_problems_problem_interpret_solution_post(self): - """Test case for problems_problem_interpret_solution_post""" - pass + code = """ + class Solution: + def twoSum(self, nums, target): + print("stdout") + return [1] + """ + test_submission = leetcode.TestSubmission( + data_input="[2,7,11,15]\n9", + typed_code=code, + question_id=1, + test_mode=False, + lang="python", + ) + + result = self._api_instance.problems_problem_interpret_solution_post( + problem="two-sum", + body=test_submission, + ) + + assert isinstance(result, Interpretation) - def test_problems_problem_submit_post(self): - """Test case for problems_problem_submit_post""" - pass - def test_submissions_detail_id_check_get(self): - """Test case for submissions_detail_id_check_get""" - pass + def test_problems_problem_submit_post(self): + code = """ + class Solution: + def twoSum(self, nums, target): + print("stdout") + return [1] + """ + + submission = leetcode.Submission( + judge_type="large", + typed_code=code, + question_id=1, + test_mode=False, + lang="python", + ) + submission_id = self._api_instance.problems_problem_submit_post( + problem="two-sum", body=submission + ) + assert isinstance(submission_id, SubmissionId) + + + sleep(5) # FIXME: should probably be a busy-waiting loop + + submission_result = self._api_instance.submissions_detail_id_check_get( + id=submission_id.submission_id + ) + # assert isinstance( + # submission_result, + # leetcode.SubmissionResult, + # ) or isinstance( + # submission_result, + # leetcode.TestSubmissionResult, + # ) + + # if isinstance(submission_result, leetcode.SubmissionResult): + # assert isinstance(submission_result.compare_result, str) + # assert isinstance(submission_result.std_output, str) + # assert isinstance(submission_result.last_testcase, str) + # assert isinstance(submission_result.expected_output, str) + # assert isinstance(submission_result.input_formatted, str) + # assert isinstance(submission_result.input, str) + # # Missing or incorrect fields + # # task_name: str + # # finished: bool + # elif isinstance(submission_result, leetcode.TestSubmissionResult): + # assert isinstance(submission_result.code_answer, list) + # assert isinstance(submission_result.correct_answer, bool) + # assert isinstance(submission_result.expected_status_code, int) + # assert isinstance(submission_result.expected_lang, str) + # assert isinstance(submission_result.expected_run_success, bool) + # assert isinstance(submission_result.expected_status_runtime, str) + # assert isinstance(submission_result.expected_memory, int) + # assert isinstance(submission_result.expected_code_answer, list) + # assert isinstance(submission_result.expected_code_output, list) + # assert isinstance(submission_result.expected_elapsed_time, int) + # assert isinstance(submission_result.expected_task_finish_time, int) + + # def test_submissions_detail_id_check_get(self): + # try: + # self._api_instance.submissions_detail_id_check_get(id="nonexistent") + # assert False + # except ApiException as e: + # assert e.status == 404 if __name__ == "__main__": diff --git a/test/test_difficulty.py b/test/test_difficulty.py index ca69804..41baf05 100644 --- a/test/test_difficulty.py +++ b/test/test_difficulty.py @@ -13,13 +13,14 @@ from __future__ import absolute_import import unittest +import test.base import leetcode from leetcode.models.difficulty import Difficulty # noqa: E501 from leetcode.rest import ApiException -class TestDifficulty(unittest.TestCase): +class TestDifficulty(test.base.BaseTest): """Difficulty unit test stubs""" def setUp(self): @@ -29,9 +30,6 @@ def tearDown(self): pass def testDifficulty(self): - """Test Difficulty""" - # FIXME: construct object with mandatory attributes with example values - # model = leetcode.models.difficulty.Difficulty() # noqa: E501 pass diff --git a/test/test_graphql_request_get_question_detail.py b/test/test_graphql_request_get_question_detail.py index 6e3fc83..b4713f5 100644 --- a/test/test_graphql_request_get_question_detail.py +++ b/test/test_graphql_request_get_question_detail.py @@ -101,7 +101,8 @@ def test_request(self) -> None: assert question.title == "Two Sum" assert question.title_slug == "two-sum" assert question.frequency == 0.0 - assert question.freq_bar > 0 + if question.freq_bar is not None: # only available for premium users + assert question.freq_bar > 0 assert len(question.content) > 10 assert question.translated_title is None assert question.is_paid_only is False @@ -124,12 +125,13 @@ def test_request(self) -> None: assert question.topic_tags[0].translated_name is None assert len(topic_tag.typename) > 0 - tag_stat = list(json.loads(question.company_tag_stats).values())[0][0] + if question.company_tag_stats is not None: # only available for premium users + tag_stat = list(json.loads(question.company_tag_stats).values())[0][0] - assert tag_stat["taggedByAdmin"] in (True, False) - assert len(tag_stat["name"]) > 0 - assert len(tag_stat["slug"]) > 0 - assert tag_stat["timesEncountered"] > 0 + assert tag_stat["taggedByAdmin"] in (True, False) + assert len(tag_stat["name"]) > 0 + assert len(tag_stat["slug"]) > 0 + assert tag_stat["timesEncountered"] > 0 code_snippet = question.code_snippets[0] @@ -169,7 +171,7 @@ def test_request(self) -> None: assert question.has_solution in (True, False) assert question.has_video_solution in (True, False) - assert question.status in ("ac", "not_started", "tried") + assert question.status in ("ac", "not_started", "tried", None) assert len(question.sample_test_case) > 0 diff --git a/test/test_graphql_request_problemset_question_list.py b/test/test_graphql_request_problemset_question_list.py index 3a79707..e57771d 100644 --- a/test/test_graphql_request_problemset_question_list.py +++ b/test/test_graphql_request_problemset_question_list.py @@ -125,7 +125,8 @@ def test_request(self) -> None: assert question.bound_topic_id is None assert question.title is not None assert question.frequency == 0.0 - assert question.freq_bar > 0 + if question.freq_bar is not None: # only available for premium users + assert question.freq_bar > 0 assert len(question.content) > 10 assert question.translated_title is None assert question.is_paid_only in (True, False) @@ -146,12 +147,13 @@ def test_request(self) -> None: assert question.topic_tags[0].translated_name is None assert len(topic_tag.typename) > 0 - tag_stat = list(json.loads(question.company_tag_stats).values())[0][0] + if question.company_tag_stats is not None: # only available for premium users + tag_stat = list(json.loads(question.company_tag_stats).values())[0][0] - assert tag_stat["taggedByAdmin"] in (True, False) - assert len(tag_stat["name"]) > 0 - assert len(tag_stat["slug"]) > 0 - assert tag_stat["timesEncountered"] > 0 + assert tag_stat["taggedByAdmin"] in (True, False) + assert len(tag_stat["name"]) > 0 + assert len(tag_stat["slug"]) > 0 + assert tag_stat["timesEncountered"] > 0 code_snippet = question.code_snippets[0] @@ -176,7 +178,9 @@ def test_request(self) -> None: assert len(code_definition["text"]) > 0 assert len(code_definition["defaultCode"]) > 0 - assert [len(hint) > 0 for hint in question.hints] + # TODO: check if the field has disappeared or if this is just a premium + # feature + # assert [len(hint) > 0 for hint in question.hints] question.solution From 9de718962af9071aab4a7bfb29457078940f143d Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Sat, 22 Mar 2025 19:12:24 +0000 Subject: [PATCH 24/24] some build infrastructure --- .github/workflows/publish-to-pypi.yml | 2 +- Dockerfile | 19 +++++++++++++++++++ README.md | 21 ++++++++++++++++++--- 3 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 Dockerfile diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index b704c43..34c6a9b 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -14,7 +14,7 @@ jobs: - name: Install requirements run: pip install -r requirements.txt - name: Build a binary wheel and a source tarball - run: python setup.py sdist + run: python setup.py sdist bdist_wheel - name: Publish distribution package to Test PyPI uses: pypa/gh-action-pypi-publish@master with: diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6a14094 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +# Test docker file +# `docker build .` verifies that the project builds and runs pytest +FROM python:3.12-slim + +# Verify wheel can be built +RUN pip install setuptools twine wheel + +WORKDIR /app + +COPY . /app/ + +RUN pip install --no-cache-dir . + +RUN python setup.py sdist bdist_wheel + +RUN python -c "import sys, leetcode; print(f'Package installed successfully in Python {sys.version}'); leetcode.DefaultApi(leetcode.ApiClient(leetcode.Configuration())); print('leetcode package is installed and functional')" + +RUN pip install pytest +RUN pytest -vvvv -s diff --git a/README.md b/README.md index ca6ce6d..0ed37ea 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ virtualenv -p python3 leetcode pip3 install python-leetcode ``` -Then in python shell initialize the client (if you're using chrome, cookies can be found here [chrome://settings/cookies/detail?site=leetcode.com](chrome://settings/cookies/detail?site=leetcode.com)) +Then in python shell initialize necessary environment variables. You can get it directly from your browser cookies (csrftoken and LEETCODE_SESSION) ```python import leetcode @@ -174,14 +174,29 @@ Autogenerated by swagger documentation can be found [here](/README.generated.md) ## Development +Build package locally and upload to test pypi +```sh +virtualenv .venv +. .venv/bin/activate +pip install setuptools twine wheel +rm -rf build/ dist/ *.egg-info/ *.egg +python setup.py sdist bdist_wheel +twine upload --repository-url https://test.pypi.org/legacy/ dist/*.whl +``` + +To run tests set up env variables and run this + +```sh +docker build --env LEETCODE_SESSION_ID=$LEETCODE_SESSION_ID --env LEETCODE_CSRF_TOKEN=$LEETCODE_CSRF_TOKEN . +``` + Test new created package before publishing ```sh -pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ python-leetcode==1.2.4 +pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ python-leetcode==1.2.5 ``` Publish package ```sh git tag 1.2.4 git push --tags - ```