From 42525ba4d890c5e17c574e4d9824e076deab94c4 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 29 Apr 2021 21:10:27 +0000 Subject: [PATCH 01/22] Upgrade to GitHub-native Dependabot --- .github/dependabot.yml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..f4952ba --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,8 @@ +version: 2 +updates: +- package-ecosystem: pip + directory: "/" + schedule: + interval: daily + time: "10:00" + open-pull-requests-limit: 10 From 70206c52e11f6fbba41dfb087aaddbef4451725d Mon Sep 17 00:00:00 2001 From: Anindya Srivastava Date: Sun, 8 Jan 2023 02:43:12 +0530 Subject: [PATCH 02/22] fixed invalid int value in .pylintrc --- .pylintrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pylintrc b/.pylintrc index ccf3cb6..dae9293 100644 --- a/.pylintrc +++ b/.pylintrc @@ -14,4 +14,4 @@ init-hook="from pylint.config import find_pylintrc; import os, sys; sys.path.app # C0330: Wrong hanging indentation (conflicts with `black`). # W0621: Redefining name from outer scope (conflicts with pytest fixtures). disable=C0122,C0330,W0621 -limit=10.0 +limit=10 From d9adea92d51613dbb60c7a2aaafd44b9539ff47e Mon Sep 17 00:00:00 2001 From: Anindya Srivastava Date: Sun, 8 Jan 2023 03:07:48 +0530 Subject: [PATCH 03/22] removed bad option values for --disable --- .pylintrc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.pylintrc b/.pylintrc index dae9293..1db55e1 100644 --- a/.pylintrc +++ b/.pylintrc @@ -10,8 +10,6 @@ ignore=conf.py init-hook="from pylint.config import find_pylintrc; import os, sys; sys.path.append(os.path.dirname(find_pylintrc()))" [pre-commit-hook] -# C0122: Misplaced comparison constant (tests use Yoda conditions). -# C0330: Wrong hanging indentation (conflicts with `black`). # W0621: Redefining name from outer scope (conflicts with pytest fixtures). -disable=C0122,C0330,W0621 +disable=W0621 limit=10 From b173435ee3918340cda7d92650339fecc319a181 Mon Sep 17 00:00:00 2001 From: Anindya Srivastava Date: Sun, 8 Jan 2023 03:23:16 +0530 Subject: [PATCH 04/22] fixed C0209 lints in countdoom/cli.py --- countdoom/cli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/countdoom/cli.py b/countdoom/cli.py index c2e03da..61b721c 100644 --- a/countdoom/cli.py +++ b/countdoom/cli.py @@ -105,7 +105,7 @@ def check_positive(value) -> int: int_value = int(value) if int_value <= 0: raise argparse.ArgumentTypeError( - "{} is an invalid positive integer value".format(value) + "{%value} is an invalid positive integer value" ) return int_value @@ -127,7 +127,7 @@ def check_positive(value) -> int: '--v', '--version', action='version', - version='%(prog)s {version}'.format(version=countdoom.__version__), + version='%(prog)s {%countdoom.__version__}', ) parser.add_argument( '-h', From da4094f8b79630382cdd45d6e2afc5fba7399156 Mon Sep 17 00:00:00 2001 From: Anindya Srivastava Date: Sun, 8 Jan 2023 03:34:43 +0530 Subject: [PATCH 05/22] fixed C0209 lints in tests/test_cli.py --- tests/test_cli.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 8c8dfe3..ed45232 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -23,7 +23,7 @@ def _setup_mock_server(mocked: aioresponses) -> None: :param mocked: aiohttp response """ - prefix = '

'.format(CountdoomClient.SELECTOR[1:]) + prefix = '

' suffix = '

' string = "IT IS 1 MINUTE TO MIDNIGHT" mocked.get( @@ -119,7 +119,7 @@ async def test_cli_request_version(capsys: CaptureFixture) -> None: assert exception.type == SystemExit assert exception.value.code == 0 - assert "countdoom {}".format(countdoom.__version__) in output[0] + assert "countdoom {%countdoom.__version__}" in output[0] @pytest.mark.asyncio @@ -271,7 +271,7 @@ async def test_cli_request_internal_error(capsys: CaptureFixture) -> None: :param capsys: System-level capture fixture """ with aioresponses() as mocked: - prefix = '

'.format(CountdoomClient.SELECTOR[1:]) + prefix = '

' suffix = '

' string = ' ' mocked.get( From ccbb67debf63469854d4a955f047c6c328bc6532 Mon Sep 17 00:00:00 2001 From: Anindya Srivastava Date: Sun, 8 Jan 2023 04:33:04 +0530 Subject: [PATCH 06/22] fixed C0209 lints in tests/test_client.py --- tests/test_client.py | 46 ++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/tests/test_client.py b/tests/test_client.py index 0085d9e..3ecea3b 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -142,7 +142,7 @@ def _setup_servers(httpserver: HTTPServer) -> None: :param httpserver: HTTP Server """ - prefix = '

'.format(CountdoomClient.SELECTOR[1:]) + prefix = f'

' suffix = '

' sentences = SENTENCES_VALID + SENTENCES_INVALID @@ -151,7 +151,7 @@ def _setup_servers(httpserver: HTTPServer) -> None: # sentences.append(sentence) for sentence in sentences: path = _get_path(sentence[0]) - httpserver.expect_request('/{}'.format(path)).respond_with_data( + httpserver.expect_request(f'/{path}').respond_with_data( prefix + sentence[0] + suffix ) @@ -197,7 +197,7 @@ async def test_valid_sentence(httpserver: HTTPServer, sentence: str) -> None: client = CountdoomClient() path = _get_path(sentence) - clock_url = httpserver.url_for('/{}'.format(path)) + clock_url = httpserver.url_for(f'/{path}') setattr(client, 'CLOCK_URL', clock_url) data = await client.fetch_data() @@ -223,7 +223,7 @@ async def test_valid_countdown( client = CountdoomClient() path = _get_path(sentence) - clock_url = httpserver.url_for('/{}'.format(path)) + clock_url = httpserver.url_for(f'/{path}') setattr(client, 'CLOCK_URL', clock_url) data = await client.fetch_data() @@ -249,7 +249,7 @@ async def test_valid_minutes( client = CountdoomClient() path = _get_path(sentence) - clock_url = httpserver.url_for('/{}'.format(path)) + clock_url = httpserver.url_for(f'/{path}') setattr(client, 'CLOCK_URL', clock_url) data = await client.fetch_data() @@ -275,7 +275,7 @@ async def test_valid_clock( client = CountdoomClient() path = _get_path(sentence) - clock_url = httpserver.url_for('/{}'.format(path)) + clock_url = httpserver.url_for(f'/{path}') setattr(client, 'CLOCK_URL', clock_url) data = await client.fetch_data() @@ -302,7 +302,7 @@ async def test_valid_time( client = CountdoomClient() path = _get_path(sentence) - clock_url = httpserver.url_for('/{}'.format(path)) + clock_url = httpserver.url_for(f'/{path}') setattr(client, 'CLOCK_URL', clock_url) data = await client.fetch_data() @@ -329,7 +329,7 @@ async def test_invalid_minutes( client = CountdoomClient() path = _get_path(sentence) - clock_url = httpserver.url_for('/{}'.format(path)) + clock_url = httpserver.url_for(f'/{path}') setattr(client, 'CLOCK_URL', clock_url) with pytest.raises(CountdoomClientError) as err: await client.fetch_data() @@ -356,7 +356,7 @@ async def test_invalid_clock( client = CountdoomClient() path = _get_path(sentence) - clock_url = httpserver.url_for('/{}'.format(path)) + clock_url = httpserver.url_for(f'/{path}') setattr(client, 'CLOCK_URL', clock_url) with pytest.raises(CountdoomClientError) as err: await client.fetch_data() @@ -383,7 +383,7 @@ async def test_invalid_time( client = CountdoomClient() path = _get_path(sentence) - clock_url = httpserver.url_for('/{}'.format(path)) + clock_url = httpserver.url_for(f'/{path}') setattr(client, 'CLOCK_URL', clock_url) with pytest.raises(CountdoomClientError) as err: await client.fetch_data() @@ -399,16 +399,16 @@ async def test_invalid_selector(httpserver: HTTPServer) -> None: :param httpserver: HTTP Server """ - prefix = '

'.format(CountdoomClient.SELECTOR[1:]) + prefix = f'

' suffix = '

' string = "IT IS 1 AND A HALF MINUTE TO MIDNIGHT" path = 'test_invalid_selector' - httpserver.expect_request('/{}'.format(path)).respond_with_data( + httpserver.expect_request(f'/{path}').respond_with_data( prefix + string + suffix ) client = CountdoomClient() - clock_url = httpserver.url_for('/{}'.format(path)) + clock_url = httpserver.url_for(f'/{path}') selector = '.wrong-id-' + str(random.randint(0, 100000000)) setattr(client, 'CLOCK_URL', clock_url) setattr(client, 'SELECTOR', selector) @@ -425,16 +425,16 @@ async def test_htmlized_sentence(httpserver: HTTPServer) -> None: :param httpserver: HTTP Server """ - prefix = '

'.format(CountdoomClient.SELECTOR[1:]) + prefix = f'

' suffix = '

' string = " IT IS STILL 1 MINUTE TO MIDNIGHT" path = 'test_htmlized_sentence' - httpserver.expect_request('/{}'.format(path)).respond_with_data( + httpserver.expect_request(f'/{path}').respond_with_data( prefix + string + suffix ) client = CountdoomClient() - clock_url = httpserver.url_for('/{}'.format(path)) + clock_url = httpserver.url_for(f'/{path}') setattr(client, 'CLOCK_URL', clock_url) data = await client.fetch_data() @@ -450,16 +450,16 @@ async def test_empty_sentence(httpserver: HTTPServer) -> None: :param httpserver: HTTP Server """ - prefix = '

'.format(CountdoomClient.SELECTOR[1:]) + prefix = f'

' suffix = '

' string = ' ' path = 'test_empty_sentence' - httpserver.expect_request('/{}'.format(path)).respond_with_data( + httpserver.expect_request(f'/{path}').respond_with_data( prefix + string + suffix ) client = CountdoomClient() - clock_url = httpserver.url_for('/{}'.format(path)) + clock_url = httpserver.url_for(f'/{path}') setattr(client, 'CLOCK_URL', clock_url) with pytest.raises(CountdoomClientError) as err: await client.fetch_data() @@ -500,16 +500,16 @@ async def test_formatted_time(httpserver: HTTPServer) -> None: :param httpserver: HTTP Server """ - prefix = '

'.format(CountdoomClient.SELECTOR[1:]) + prefix = f'

' suffix = '

' string = "IT IS 16 MINUTES TO MIDNIGHT" path = 'test_formatted_time' - httpserver.expect_request('/{}'.format(path)).respond_with_data( + httpserver.expect_request(f'/{path}').respond_with_data( prefix + string + suffix ) client = CountdoomClient() - clock_url = httpserver.url_for('/{}'.format(path)) + clock_url = httpserver.url_for(f'/{path}') setattr(client, 'CLOCK_URL', clock_url) data = await client.fetch_data() @@ -526,7 +526,7 @@ async def test_url_not_found(httpserver: HTTPServer) -> None: """ path = 'test_url_not_found' client = CountdoomClient() - clock_url = httpserver.url_for('/{}'.format(path)) + clock_url = httpserver.url_for(f'/{path}') setattr(client, 'CLOCK_URL', clock_url) with pytest.raises(CountdoomClientError) as err: await client.fetch_data() From 8db8ab3944fb4c04546893bcb035320aba3bb5fe Mon Sep 17 00:00:00 2001 From: Anindya Srivastava Date: Sun, 8 Jan 2023 04:48:06 +0530 Subject: [PATCH 07/22] fixed a C0209 bug in commits b173435 and da4094f --- countdoom/cli.py | 4 ++-- tests/test_cli.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/countdoom/cli.py b/countdoom/cli.py index 61b721c..a390f0d 100644 --- a/countdoom/cli.py +++ b/countdoom/cli.py @@ -105,7 +105,7 @@ def check_positive(value) -> int: int_value = int(value) if int_value <= 0: raise argparse.ArgumentTypeError( - "{%value} is an invalid positive integer value" + f"{value} is an invalid positive integer value" ) return int_value @@ -127,7 +127,7 @@ def check_positive(value) -> int: '--v', '--version', action='version', - version='%(prog)s {%countdoom.__version__}', + version=f'%(prog)s {countdoom.__version__}', ) parser.add_argument( '-h', diff --git a/tests/test_cli.py b/tests/test_cli.py index ed45232..d603725 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -23,7 +23,7 @@ def _setup_mock_server(mocked: aioresponses) -> None: :param mocked: aiohttp response """ - prefix = '

' + prefix = f'

' suffix = '

' string = "IT IS 1 MINUTE TO MIDNIGHT" mocked.get( @@ -119,7 +119,7 @@ async def test_cli_request_version(capsys: CaptureFixture) -> None: assert exception.type == SystemExit assert exception.value.code == 0 - assert "countdoom {%countdoom.__version__}" in output[0] + assert f"countdoom {countdoom.__version__}" in output[0] @pytest.mark.asyncio @@ -271,7 +271,7 @@ async def test_cli_request_internal_error(capsys: CaptureFixture) -> None: :param capsys: System-level capture fixture """ with aioresponses() as mocked: - prefix = '

' + prefix = f'

' suffix = '

' string = ' ' mocked.get( From 91aa63c9f932f51427bf1a4b3c3461e6385dd205 Mon Sep 17 00:00:00 2001 From: Anindya Srivastava Date: Sun, 8 Jan 2023 04:52:37 +0530 Subject: [PATCH 08/22] fixed C0209 lints in tests/test_package.py --- tests/test_package.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_package.py b/tests/test_package.py index 468428c..26661cd 100644 --- a/tests/test_package.py +++ b/tests/test_package.py @@ -26,4 +26,4 @@ def test_package_main() -> None: ) stdout = process.communicate()[0] - assert 'countdoom {}'.format(countdoom.__version__) in str(stdout) + assert f'countdoom {countdoom.__version__}' in str(stdout) From e81d473d116efbcc6925e994593488b125a17eaf Mon Sep 17 00:00:00 2001 From: Anindya Srivastava Date: Sun, 8 Jan 2023 04:55:30 +0530 Subject: [PATCH 09/22] fixed R1732 lints in tests/test_package.py --- tests/test_package.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_package.py b/tests/test_package.py index 26661cd..8356388 100644 --- a/tests/test_package.py +++ b/tests/test_package.py @@ -19,11 +19,11 @@ def test_package_main() -> None: This check uses a subprocess to validate the package, since the package's __main__.py cannot be imported for tests. """ - process = subprocess.Popen( + with subprocess.Popen( ['python', '-m', 'countdoom', '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, - ) - stdout = process.communicate()[0] + ) as process: + stdout = process.communicate()[0] assert f'countdoom {countdoom.__version__}' in str(stdout) From 586944166412e7686b6c7d04aec0602bbfa5310f Mon Sep 17 00:00:00 2001 From: Anindya Srivastava Date: Sun, 8 Jan 2023 05:12:02 +0530 Subject: [PATCH 10/22] fixed W0707 lints in countdoom/client.py --- countdoom/client.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/countdoom/client.py b/countdoom/client.py index 9baf7f1..4dc1f97 100644 --- a/countdoom/client.py +++ b/countdoom/client.py @@ -165,12 +165,12 @@ async def _fetch(self, url: str, timeout: int = None) -> str: if resp.status != 200: raise AssertionError return await resp.text() - except AssertionError: + except AssertionError as exc: await self.close() - raise CountdoomClientError("Page not found.") - except OSError: + raise CountdoomClientError("Page not found.") from exc + except OSError as exc: await self.close() - raise CountdoomClientError("Cannot connect to website. Check URL.") + raise CountdoomClientError("Cannot connect to website. Check URL.") from exc async def _extract_sentence(self) -> None: """ @@ -187,20 +187,20 @@ async def _extract_sentence(self) -> None: self._sentence = re.sub(r'\s+', ' ', sentence).strip() if not self._sentence: raise ValueError() - except IndexError: + except IndexError as exc: _LOGGER.error( "No sentence found using selector %s. Check for source " "website design changes.", self.SELECTOR, ) - raise CountdoomClientError("No sentence found.") - except ValueError: + raise CountdoomClientError("No sentence found.") from exc + except ValueError as exc: _LOGGER.error( "Empty sentence found using selector %s. Check for source " "website design changes.", self.SELECTOR, ) - raise CountdoomClientError("Empty sentence found.") + raise CountdoomClientError("Empty sentence found.") from exc _LOGGER.debug("Sentence found: %s", self._sentence) async def close(self) -> None: @@ -223,11 +223,11 @@ def _sentence_to_countdown(self) -> None: try: self._countdown = self.sentence_to_countdown(self._sentence) - except AttributeError: + except AttributeError as exc: _LOGGER.error( "Regex pattern yielded no result for : %s", self._sentence ) - raise CountdoomClientError("Sentence not parsable.") + raise CountdoomClientError("Sentence not parsable.") from exc _LOGGER.debug("Countdown value: %s", self._countdown) @classmethod From f678c3062796e5b3aa624157b972562fdd600c2e Mon Sep 17 00:00:00 2001 From: Anindya Srivastava Date: Sun, 8 Jan 2023 07:06:10 +0530 Subject: [PATCH 11/22] python 3.5 has reached end of life, removing from tox --- tox.ini | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index ff18480..a4d76a1 100644 --- a/tox.ini +++ b/tox.ini @@ -6,7 +6,7 @@ # See https://tox.readthedocs.io/ [tox] -envlist = lint, py3{5,6,7,8}, pypy3 +envlist = lint, py3{6,7,8}, pypy3 skip_missing_interpreters = true [travis] @@ -14,7 +14,6 @@ python = 3.8: py38 3.7: py37 3.6: py36 - 3.5: py35 [testenv] setenv = From 1be3d335e0e7d580f211de641e921aabff6bd0c2 Mon Sep 17 00:00:00 2001 From: Anindya Srivastava Date: Sun, 8 Jan 2023 07:15:00 +0530 Subject: [PATCH 12/22] remove python3.5 from travis --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4f83f82..2d73e11 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,6 @@ python: - "3.8" - "3.7" - "3.6" - - "3.5" # Disabled until typed_ast (used by pylint) is fixed. # See https://github.com/python/typed_ast/issues/134 # - "pypy3" From 83084c6e225b1ca100d550291cf51810326a5fda Mon Sep 17 00:00:00 2001 From: Anindya Srivastava Date: Sun, 8 Jan 2023 07:23:02 +0530 Subject: [PATCH 13/22] fixed E501 lint --- countdoom/client.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/countdoom/client.py b/countdoom/client.py index 4dc1f97..09f7ff8 100644 --- a/countdoom/client.py +++ b/countdoom/client.py @@ -170,7 +170,9 @@ async def _fetch(self, url: str, timeout: int = None) -> str: raise CountdoomClientError("Page not found.") from exc except OSError as exc: await self.close() - raise CountdoomClientError("Cannot connect to website. Check URL.") from exc + raise CountdoomClientError( + "Cannot connect to website. Check URL." + ) from exc async def _extract_sentence(self) -> None: """ From 83f14bf07851ce67c7a6bfeb88086db87c594002 Mon Sep 17 00:00:00 2001 From: Anindya Srivastava Date: Sun, 8 Jan 2023 07:25:44 +0530 Subject: [PATCH 14/22] bugfix --- countdoom/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/countdoom/client.py b/countdoom/client.py index 09f7ff8..2ed88f4 100644 --- a/countdoom/client.py +++ b/countdoom/client.py @@ -172,7 +172,7 @@ async def _fetch(self, url: str, timeout: int = None) -> str: await self.close() raise CountdoomClientError( "Cannot connect to website. Check URL." - ) from exc + ) from exc async def _extract_sentence(self) -> None: """ From 5a717837174309846267eaa8b72dc7ccc49dc6e2 Mon Sep 17 00:00:00 2001 From: Anindya Srivastava Date: Sun, 8 Jan 2023 07:33:42 +0530 Subject: [PATCH 15/22] added timeout to get request --- tests/test_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_client.py b/tests/test_client.py index 3ecea3b..d87bb04 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -122,7 +122,7 @@ def response() -> Response: :return: Request response """ - return requests.get(CountdoomClient.CLOCK_URL) + return requests.get(CountdoomClient.CLOCK_URL, timeout=5) def _get_path(string: str) -> str: From 7e283251e7a69de3dbc0202cd0ba5afef69655f4 Mon Sep 17 00:00:00 2001 From: Anindya Srivastava Date: Sun, 8 Jan 2023 07:44:16 +0530 Subject: [PATCH 16/22] replacing deprecated option --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index fc7ad27..cbe15b9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -31,6 +31,6 @@ ignore_missing_imports = true # See https://docs.pytest.org/ [tool:pytest] collect_ignore = ['setup.py'] -addopts = --strict +addopts = --strict-markers markers = live From df4405a8e12415639a9500fcb2d3360e2e1d28d4 Mon Sep 17 00:00:00 2001 From: Anindya Srivastava Date: Sun, 8 Jan 2023 07:49:51 +0530 Subject: [PATCH 17/22] replaced collect-ignore with ignore option --- setup.cfg | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index cbe15b9..1bb3986 100644 --- a/setup.cfg +++ b/setup.cfg @@ -30,7 +30,8 @@ ignore_missing_imports = true # Configure pytest # See https://docs.pytest.org/ [tool:pytest] -collect_ignore = ['setup.py'] -addopts = --strict-markers +addopts = + --ignore=setup.py, + --strict-markers markers = live From 7265d573366e636475aa9c7e7d4d262b64032cd2 Mon Sep 17 00:00:00 2001 From: Anindya Srivastava Date: Sun, 8 Jan 2023 08:09:59 +0530 Subject: [PATCH 18/22] switched to f-strings in setup.py --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 2ae4a47..ed8b1c0 100644 --- a/setup.py +++ b/setup.py @@ -88,9 +88,9 @@ # Define URLs. DOCS_URL = 'https://countdoom.readthedocs.io/' -HISTORY_URL = '{}en/latest/changelog.html'.format(DOCS_URL) +HISTORY_URL = f'{DOCS_URL}en/latest/changelog.html' REPO_URL = 'https://github.com/renemarc/countdoom' -ISSUES_URL = '{}/issues'.format(REPO_URL) +ISSUES_URL = f'{REPO_URL}/issues' setup( author='René-Marc Simard', From b7c7a4f4446e8c66ad0d0aa03e1e39c6786d4fb5 Mon Sep 17 00:00:00 2001 From: Anindya Srivastava Date: Sun, 8 Jan 2023 08:12:51 +0530 Subject: [PATCH 19/22] added utf-8 encoding to open methods in setup.py --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index ed8b1c0..8d2b2d3 100644 --- a/setup.py +++ b/setup.py @@ -15,10 +15,10 @@ from setuptools import find_packages, setup # Load documentation for PyPI. -with open('README.rst') as readme_file: +with open('README.rst', encoding="utf-8") as readme_file: README = readme_file.read() -with open('CHANGELOG.rst') as history_file: +with open('CHANGELOG.rst', encoding="utf-8") as history_file: HISTORY = history_file.read() # Define extra requirements for different installation environments. From 0460edd40e6d9f02d7c8da2d2a9e4654061178a7 Mon Sep 17 00:00:00 2001 From: Anindya Srivastava Date: Sun, 8 Jan 2023 08:57:24 +0530 Subject: [PATCH 20/22] merged nested async with statements --- countdoom/client.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/countdoom/client.py b/countdoom/client.py index 2ed88f4..821e299 100644 --- a/countdoom/client.py +++ b/countdoom/client.py @@ -160,11 +160,10 @@ async def _fetch(self, url: str, timeout: int = None) -> str: raise CountdoomClientError("Session not started.") try: - async with async_timeout.timeout(timeout): - async with self._session.get(url, timeout=timeout) as resp: - if resp.status != 200: - raise AssertionError - return await resp.text() + async with async_timeout.timeout(timeout), self._session.get(url, timeout=timeout) as resp: + if resp.status != 200: + raise AssertionError + return await resp.text() except AssertionError as exc: await self.close() raise CountdoomClientError("Page not found.") from exc From 0214fbd46e0b7f29f2f5df27b999573610516723 Mon Sep 17 00:00:00 2001 From: Anindya Srivastava Date: Sun, 8 Jan 2023 08:58:19 +0530 Subject: [PATCH 21/22] removed commented out code block --- tests/test_client.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/test_client.py b/tests/test_client.py index d87bb04..bdb325d 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -146,9 +146,6 @@ def _setup_servers(httpserver: HTTPServer) -> None: suffix = '' sentences = SENTENCES_VALID + SENTENCES_INVALID - # sentences = SENTENCES_VALID - # for sentence in SENTENCES_INVALID: - # sentences.append(sentence) for sentence in sentences: path = _get_path(sentence[0]) httpserver.expect_request(f'/{path}').respond_with_data( From 17f3f205fa295d4ddde773ace0979cfdb637a2d2 Mon Sep 17 00:00:00 2001 From: Anindya Srivastava Date: Sun, 8 Jan 2023 09:10:11 +0530 Subject: [PATCH 22/22] line too long --- countdoom/client.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/countdoom/client.py b/countdoom/client.py index 821e299..35060bc 100644 --- a/countdoom/client.py +++ b/countdoom/client.py @@ -160,7 +160,10 @@ async def _fetch(self, url: str, timeout: int = None) -> str: raise CountdoomClientError("Session not started.") try: - async with async_timeout.timeout(timeout), self._session.get(url, timeout=timeout) as resp: + async with ( + async_timeout.timeout(timeout), + self._session.get(url, timeout=timeout) as resp + ): if resp.status != 200: raise AssertionError return await resp.text()