From 2428a100567e69e6f17f682c2d0b34bcfa5d3838 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 28 Mar 2021 03:57:47 +0200 Subject: [PATCH 01/33] Experiment: monkeytype stub web_programming --- .github/workflows/monkeytype.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/monkeytype.yml diff --git a/.github/workflows/monkeytype.yml b/.github/workflows/monkeytype.yml new file mode 100644 index 000000000000..3b82fab21dbc --- /dev/null +++ b/.github/workflows/monkeytype.yml @@ -0,0 +1,24 @@ +name: "build" + +on: + pull_request: + schedule: + - cron: "0 0 * * *" # Run everyday + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: "3.9" + - uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip setuptools wheel + python -m pip install monkeytype -r requirements.txt + - run: monkeytype stub web_programming From 1ef01e70c3cc38c325a44e1916e004140787694b Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 28 Mar 2021 04:06:56 +0200 Subject: [PATCH 02/33] pytest --doctest-modules web_programming --- .github/workflows/monkeytype.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/monkeytype.yml b/.github/workflows/monkeytype.yml index 3b82fab21dbc..a2671e9e47fd 100644 --- a/.github/workflows/monkeytype.yml +++ b/.github/workflows/monkeytype.yml @@ -1,18 +1,14 @@ -name: "build" +name: monkeytype on: pull_request: - schedule: - - cron: "0 0 * * *" # Run everyday jobs: - build: + monkeytype: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 - with: - python-version: "3.9" - uses: actions/cache@v2 with: path: ~/.cache/pip @@ -20,5 +16,6 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip setuptools wheel - python -m pip install monkeytype -r requirements.txt + python -m pip install monkeytype pytest -r requirements.txt + - run: pytest --doctest-modules web_programming - run: monkeytype stub web_programming From aaea82136924a166533ecafb81576e4961c5024c Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 28 Mar 2021 04:15:04 +0200 Subject: [PATCH 03/33] world_covid19_stats.py --- .github/workflows/monkeytype.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/monkeytype.yml b/.github/workflows/monkeytype.yml index a2671e9e47fd..066bb4859118 100644 --- a/.github/workflows/monkeytype.yml +++ b/.github/workflows/monkeytype.yml @@ -17,5 +17,6 @@ jobs: run: | python -m pip install --upgrade pip setuptools wheel python -m pip install monkeytype pytest -r requirements.txt - - run: pytest --doctest-modules web_programming - - run: monkeytype stub web_programming + - run: pytest --doctest-modules arithmetic_analysis/gaussian_elimination.py web_programming + - run: monkeytype stub arithmetic_analysis/gaussian_elimination.py + - run: monkeytype stub web_programming/world_covid19_stats.py From 6b969697927ce967c71a014918344f5fd6bd5333 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 28 Mar 2021 04:18:27 +0200 Subject: [PATCH 04/33] monkeytype stub web_programming.world_covid19_stats --- .github/workflows/monkeytype.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/monkeytype.yml b/.github/workflows/monkeytype.yml index 066bb4859118..83c33765f93c 100644 --- a/.github/workflows/monkeytype.yml +++ b/.github/workflows/monkeytype.yml @@ -18,5 +18,5 @@ jobs: python -m pip install --upgrade pip setuptools wheel python -m pip install monkeytype pytest -r requirements.txt - run: pytest --doctest-modules arithmetic_analysis/gaussian_elimination.py web_programming - - run: monkeytype stub arithmetic_analysis/gaussian_elimination.py - - run: monkeytype stub web_programming/world_covid19_stats.py + - run: monkeytype stub arithmetic_analysis.gaussian_elimination + - run: monkeytype stub web_programming.world_covid19_stats From 2220b885c6f2c153d3b400609c4e8c75c7910205 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 28 Mar 2021 04:28:04 +0200 Subject: [PATCH 05/33] Create monkeytype_config.py --- monkeytype_config.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 monkeytype_config.py diff --git a/monkeytype_config.py b/monkeytype_config.py new file mode 100644 index 000000000000..9ddc0078d3fb --- /dev/null +++ b/monkeytype_config.py @@ -0,0 +1,7 @@ +from monkeytype.config import DefaultConfig + +class MyConfig(DefaultConfig): + def sample_rate(self): + return 1000 + +CONFIG = MyConfig() From 484855ca1d33b709f7abc3972fec7220a1b97aff Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Sun, 28 Mar 2021 02:28:24 +0000 Subject: [PATCH 06/33] updating DIRECTORY.md --- DIRECTORY.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DIRECTORY.md b/DIRECTORY.md index 42a6c49c735f..0901415ba362 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -521,6 +521,8 @@ * Tests * [Test Matrix Operation](https://github.com/TheAlgorithms/Python/blob/master/matrix/tests/test_matrix_operation.py) +## [Monkeytype Config](https://github.com/TheAlgorithms/Python/blob/master//monkeytype_config.py) + ## Networking Flow * [Ford Fulkerson](https://github.com/TheAlgorithms/Python/blob/master/networking_flow/ford_fulkerson.py) * [Minimum Cut](https://github.com/TheAlgorithms/Python/blob/master/networking_flow/minimum_cut.py) From 6570772a38f92c1802f128cbe671ae6686890c85 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 28 Mar 2021 08:48:16 +0200 Subject: [PATCH 07/33] monkeytype run pytest --doctest-modules --- .github/workflows/monkeytype.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/monkeytype.yml b/.github/workflows/monkeytype.yml index 83c33765f93c..4bda7ca365b6 100644 --- a/.github/workflows/monkeytype.yml +++ b/.github/workflows/monkeytype.yml @@ -17,6 +17,6 @@ jobs: run: | python -m pip install --upgrade pip setuptools wheel python -m pip install monkeytype pytest -r requirements.txt - - run: pytest --doctest-modules arithmetic_analysis/gaussian_elimination.py web_programming + - run: monkeytype run pytest --doctest-modules arithmetic_analysis/gaussian_elimination.py web_programming - run: monkeytype stub arithmetic_analysis.gaussian_elimination - run: monkeytype stub web_programming.world_covid19_stats From 73712f16c3a24b8c2942f502fc728a53b8010271 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 28 Mar 2021 08:54:15 +0200 Subject: [PATCH 08/33] monkeytype run python3 -m pytest --doctest-modules --- .github/workflows/monkeytype.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/monkeytype.yml b/.github/workflows/monkeytype.yml index 4bda7ca365b6..0c9d0288938b 100644 --- a/.github/workflows/monkeytype.yml +++ b/.github/workflows/monkeytype.yml @@ -17,6 +17,6 @@ jobs: run: | python -m pip install --upgrade pip setuptools wheel python -m pip install monkeytype pytest -r requirements.txt - - run: monkeytype run pytest --doctest-modules arithmetic_analysis/gaussian_elimination.py web_programming + - run: monkeytype run python3 -m pytest --doctest-modules arithmetic_analysis/gaussian_elimination.py web_programming - run: monkeytype stub arithmetic_analysis.gaussian_elimination - run: monkeytype stub web_programming.world_covid19_stats From bb8909f351708926d7f17cd8edb10a47bd07c668 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 28 Mar 2021 11:05:21 +0200 Subject: [PATCH 09/33] Update monkeytype.yml --- .github/workflows/monkeytype.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/monkeytype.yml b/.github/workflows/monkeytype.yml index 0c9d0288938b..9b82c8fa246b 100644 --- a/.github/workflows/monkeytype.yml +++ b/.github/workflows/monkeytype.yml @@ -9,6 +9,8 @@ jobs: steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 + - run: which python3 || true + - run: whereis python3 || true - uses: actions/cache@v2 with: path: ~/.cache/pip From 5480ec4636ad31b9dfe19e710c769c632d3b65d3 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 28 Mar 2021 11:07:06 +0200 Subject: [PATCH 10/33] /opt/hostedtoolcache/Python/3.9.2/x64/bin/python3/opt/hostedtoolcache/Python/3.9.2/x64/bin/python3/opt/hostedtoolcache/Python/3.9.2/x64/bin/python3 --- .github/workflows/monkeytype.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/monkeytype.yml b/.github/workflows/monkeytype.yml index 9b82c8fa246b..1f2c63ed7bcd 100644 --- a/.github/workflows/monkeytype.yml +++ b/.github/workflows/monkeytype.yml @@ -19,6 +19,6 @@ jobs: run: | python -m pip install --upgrade pip setuptools wheel python -m pip install monkeytype pytest -r requirements.txt - - run: monkeytype run python3 -m pytest --doctest-modules arithmetic_analysis/gaussian_elimination.py web_programming + - run: monkeytype run /opt/hostedtoolcache/Python/3.9.2/x64/bin/python3 -m pytest --doctest-modules arithmetic_analysis/gaussian_elimination.py web_programming - run: monkeytype stub arithmetic_analysis.gaussian_elimination - run: monkeytype stub web_programming.world_covid19_stats From ccf7acff9bc9c15b40244d51ffbb6e9f4e6a8203 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 28 Mar 2021 11:21:19 +0200 Subject: [PATCH 11/33] Update monkeytype.yml --- .github/workflows/monkeytype.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/monkeytype.yml b/.github/workflows/monkeytype.yml index 1f2c63ed7bcd..3672713265ad 100644 --- a/.github/workflows/monkeytype.yml +++ b/.github/workflows/monkeytype.yml @@ -19,6 +19,7 @@ jobs: run: | python -m pip install --upgrade pip setuptools wheel python -m pip install monkeytype pytest -r requirements.txt - - run: monkeytype run /opt/hostedtoolcache/Python/3.9.2/x64/bin/python3 -m pytest --doctest-modules arithmetic_analysis/gaussian_elimination.py web_programming + - run: monkeytype run arithmetic_analysis/gaussian_elimination.py web_programming - run: monkeytype stub arithmetic_analysis.gaussian_elimination + - run: monkeytype run web_programming/world_covid19_stats.py - run: monkeytype stub web_programming.world_covid19_stats From 2df9939dc58ca48acc1a1a5f86a552d2c44ab37e Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 28 Mar 2021 11:26:51 +0200 Subject: [PATCH 12/33] Update monkeytype.yml --- .github/workflows/monkeytype.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/monkeytype.yml b/.github/workflows/monkeytype.yml index 3672713265ad..5b7eda727735 100644 --- a/.github/workflows/monkeytype.yml +++ b/.github/workflows/monkeytype.yml @@ -23,3 +23,5 @@ jobs: - run: monkeytype stub arithmetic_analysis.gaussian_elimination - run: monkeytype run web_programming/world_covid19_stats.py - run: monkeytype stub web_programming.world_covid19_stats + - run: monkeytype stub web_programming + - run: monkeytype stub || true From 5ed45b34d5ee6f57c9765fc4ef07a24991f43f2c Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 28 Mar 2021 11:45:33 +0200 Subject: [PATCH 13/33] monkeytype run web_programming/*.py --- .github/workflows/monkeytype.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/monkeytype.yml b/.github/workflows/monkeytype.yml index 5b7eda727735..0df91b86b08a 100644 --- a/.github/workflows/monkeytype.yml +++ b/.github/workflows/monkeytype.yml @@ -21,7 +21,7 @@ jobs: python -m pip install monkeytype pytest -r requirements.txt - run: monkeytype run arithmetic_analysis/gaussian_elimination.py web_programming - run: monkeytype stub arithmetic_analysis.gaussian_elimination - - run: monkeytype run web_programming/world_covid19_stats.py + - run: monkeytype run web_programming/*.py - run: monkeytype stub web_programming.world_covid19_stats - run: monkeytype stub web_programming - run: monkeytype stub || true From 7ab64b375b6584a2a57367d8942ceee1b7eec2ae Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 28 Mar 2021 12:04:24 +0200 Subject: [PATCH 14/33] monkeytype list-modules --- .github/workflows/monkeytype.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/monkeytype.yml b/.github/workflows/monkeytype.yml index 0df91b86b08a..2b5e20c0e35c 100644 --- a/.github/workflows/monkeytype.yml +++ b/.github/workflows/monkeytype.yml @@ -22,6 +22,8 @@ jobs: - run: monkeytype run arithmetic_analysis/gaussian_elimination.py web_programming - run: monkeytype stub arithmetic_analysis.gaussian_elimination - run: monkeytype run web_programming/*.py + - run: monkeytype list-modules - run: monkeytype stub web_programming.world_covid19_stats - run: monkeytype stub web_programming - run: monkeytype stub || true + - run: monkeytype list-modules From b532d22080a1bbb2d26f42dfb97bbdabaaca8495 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 28 Mar 2021 12:13:41 +0200 Subject: [PATCH 15/33] Update monkeytype.yml --- .github/workflows/monkeytype.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/monkeytype.yml b/.github/workflows/monkeytype.yml index 2b5e20c0e35c..433a789658a9 100644 --- a/.github/workflows/monkeytype.yml +++ b/.github/workflows/monkeytype.yml @@ -21,7 +21,8 @@ jobs: python -m pip install monkeytype pytest -r requirements.txt - run: monkeytype run arithmetic_analysis/gaussian_elimination.py web_programming - run: monkeytype stub arithmetic_analysis.gaussian_elimination - - run: monkeytype run web_programming/*.py + - run: monkeytype run web_programming/world_covid19_stats.py + - run: monkeytype run web_programmingy - run: monkeytype list-modules - run: monkeytype stub web_programming.world_covid19_stats - run: monkeytype stub web_programming From 7a14b85c3ea8b4446e7dc4c3d3fd06eb55d0a7dc Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 28 Mar 2021 12:19:31 +0200 Subject: [PATCH 16/33] Update monkeytype.yml --- .github/workflows/monkeytype.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/monkeytype.yml b/.github/workflows/monkeytype.yml index 433a789658a9..4eb83d714d6d 100644 --- a/.github/workflows/monkeytype.yml +++ b/.github/workflows/monkeytype.yml @@ -22,7 +22,7 @@ jobs: - run: monkeytype run arithmetic_analysis/gaussian_elimination.py web_programming - run: monkeytype stub arithmetic_analysis.gaussian_elimination - run: monkeytype run web_programming/world_covid19_stats.py - - run: monkeytype run web_programmingy + - run: monkeytype run web_programming - run: monkeytype list-modules - run: monkeytype stub web_programming.world_covid19_stats - run: monkeytype stub web_programming From 709030206f3bfb730edb59ba6724e72348228333 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 28 Mar 2021 12:28:57 +0200 Subject: [PATCH 17/33] Update monkeytype.yml --- .github/workflows/monkeytype.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/monkeytype.yml b/.github/workflows/monkeytype.yml index 4eb83d714d6d..29c2d8d459cf 100644 --- a/.github/workflows/monkeytype.yml +++ b/.github/workflows/monkeytype.yml @@ -22,7 +22,7 @@ jobs: - run: monkeytype run arithmetic_analysis/gaussian_elimination.py web_programming - run: monkeytype stub arithmetic_analysis.gaussian_elimination - run: monkeytype run web_programming/world_covid19_stats.py - - run: monkeytype run web_programming + - run: monkeytype run web_programming/*.py - run: monkeytype list-modules - run: monkeytype stub web_programming.world_covid19_stats - run: monkeytype stub web_programming From dcd5109048d64570f527e0219a6c5c1552491144 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 28 Mar 2021 13:02:30 +0200 Subject: [PATCH 18/33] pyannotate --- .github/workflows/monkeytype.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/monkeytype.yml b/.github/workflows/monkeytype.yml index 29c2d8d459cf..5c8db4861246 100644 --- a/.github/workflows/monkeytype.yml +++ b/.github/workflows/monkeytype.yml @@ -18,7 +18,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip setuptools wheel - python -m pip install monkeytype pytest -r requirements.txt + python -m pip install monkeytype pyannotate pytest -r requirements.txt - run: monkeytype run arithmetic_analysis/gaussian_elimination.py web_programming - run: monkeytype stub arithmetic_analysis.gaussian_elimination - run: monkeytype run web_programming/world_covid19_stats.py @@ -28,3 +28,4 @@ jobs: - run: monkeytype stub web_programming - run: monkeytype stub || true - run: monkeytype list-modules + - run: cat type_info.json || true From 560de389807048e2335d84b4f4f9b406f6914be8 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 28 Mar 2021 13:04:41 +0200 Subject: [PATCH 19/33] from pyannotate_runtime import collect_types --- web_programming/world_covid19_stats.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/web_programming/world_covid19_stats.py b/web_programming/world_covid19_stats.py index 1dd1ff6d188e..285f0b6d0ec2 100644 --- a/web_programming/world_covid19_stats.py +++ b/web_programming/world_covid19_stats.py @@ -22,6 +22,10 @@ def world_covid19_stats(url: str = "https://www.worldometers.info/coronavirus") if __name__ == "__main__": - print("\033[1m" + "COVID-19 Status of the World" + "\033[0m\n") - for key, value in world_covid19_stats().items(): - print(f"{key}\n{value}\n") + from pyannotate_runtime import collect_types + collect_types.init_types_collection() + with collect_types.collect(): + print("\033[1m" + "COVID-19 Status of the World" + "\033[0m\n") + for key, value in world_covid19_stats().items(): + print(f"{key}\n{value}\n") + collect_types.dump_stats('type_info.json') From 3546524bbc3c413c89c59a7ee73bfe50fd39a927 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 28 Mar 2021 13:51:38 +0200 Subject: [PATCH 20/33] typing: API_KEY is a str --- web_programming/currency_converter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_programming/currency_converter.py b/web_programming/currency_converter.py index 6aed2a5578a5..447595b0b646 100644 --- a/web_programming/currency_converter.py +++ b/web_programming/currency_converter.py @@ -9,7 +9,7 @@ URL_BASE = "https://www.amdoren.com/api/currency.php" TESTING = os.getenv("CI", False) -API_KEY = os.getenv("AMDOREN_API_KEY") +API_KEY = os.getenv("AMDOREN_API_KEY", "") if not API_KEY and not TESTING: raise KeyError("Please put your API key in an environment variable.") From da9ec61473170a8e6aa1301fd43dc2deae889ed7 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 28 Mar 2021 13:56:54 +0200 Subject: [PATCH 21/33] pyannotate emails_from_url.py --- web_programming/emails_from_url.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/web_programming/emails_from_url.py b/web_programming/emails_from_url.py index 01dee274f015..0757ae6895e5 100644 --- a/web_programming/emails_from_url.py +++ b/web_programming/emails_from_url.py @@ -98,6 +98,10 @@ def emails_from_url(url: str = "https://github.com") -> list: if __name__ == "__main__": - emails = emails_from_url("https://github.com") - print(f"{len(emails)} emails found:") - print("\n".join(sorted(emails))) + from pyannotate_runtime import collect_types + collect_types.init_types_collection() + with collect_types.collect(): + emails = emails_from_url("https://github.com") + print(f"{len(emails)} emails found:") + print("\n".join(sorted(emails))) + collect_types.dump_stats('type_info.json') From 8cc34cd582ae52e8d069ec8fed44fef6aaf3450f Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 28 Mar 2021 14:03:29 +0200 Subject: [PATCH 22/33] pyannotate web_programming/emails_from_url.py --- .github/workflows/monkeytype.yml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/.github/workflows/monkeytype.yml b/.github/workflows/monkeytype.yml index 5c8db4861246..ee2bfa9e388f 100644 --- a/.github/workflows/monkeytype.yml +++ b/.github/workflows/monkeytype.yml @@ -18,14 +18,6 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip setuptools wheel - python -m pip install monkeytype pyannotate pytest -r requirements.txt - - run: monkeytype run arithmetic_analysis/gaussian_elimination.py web_programming - - run: monkeytype stub arithmetic_analysis.gaussian_elimination - - run: monkeytype run web_programming/world_covid19_stats.py - - run: monkeytype run web_programming/*.py - - run: monkeytype list-modules - - run: monkeytype stub web_programming.world_covid19_stats - - run: monkeytype stub web_programming - - run: monkeytype stub || true - - run: monkeytype list-modules + python -m pip install pyannotate pytest -r requirements.txt + - run: python3 web_programming/emails_from_url.py - run: cat type_info.json || true From d649a7049e72ac45b156b3a1db5a62ef9066b613 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 28 Mar 2021 14:04:57 +0200 Subject: [PATCH 23/33] Update world_covid19_stats.py --- web_programming/world_covid19_stats.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/web_programming/world_covid19_stats.py b/web_programming/world_covid19_stats.py index 285f0b6d0ec2..1dd1ff6d188e 100644 --- a/web_programming/world_covid19_stats.py +++ b/web_programming/world_covid19_stats.py @@ -22,10 +22,6 @@ def world_covid19_stats(url: str = "https://www.worldometers.info/coronavirus") if __name__ == "__main__": - from pyannotate_runtime import collect_types - collect_types.init_types_collection() - with collect_types.collect(): - print("\033[1m" + "COVID-19 Status of the World" + "\033[0m\n") - for key, value in world_covid19_stats().items(): - print(f"{key}\n{value}\n") - collect_types.dump_stats('type_info.json') + print("\033[1m" + "COVID-19 Status of the World" + "\033[0m\n") + for key, value in world_covid19_stats().items(): + print(f"{key}\n{value}\n") From 5178056dbb7bf7ce646a4f4919c0c95e3a8c3172 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 28 Mar 2021 14:05:31 +0200 Subject: [PATCH 24/33] Delete monkeytype_config.py --- monkeytype_config.py | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 monkeytype_config.py diff --git a/monkeytype_config.py b/monkeytype_config.py deleted file mode 100644 index 9ddc0078d3fb..000000000000 --- a/monkeytype_config.py +++ /dev/null @@ -1,7 +0,0 @@ -from monkeytype.config import DefaultConfig - -class MyConfig(DefaultConfig): - def sample_rate(self): - return 1000 - -CONFIG = MyConfig() From a2f7d424c159b4aa1fcab3458a3378597f7751b9 Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Sun, 28 Mar 2021 12:05:51 +0000 Subject: [PATCH 25/33] updating DIRECTORY.md --- DIRECTORY.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/DIRECTORY.md b/DIRECTORY.md index 0901415ba362..42a6c49c735f 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -521,8 +521,6 @@ * Tests * [Test Matrix Operation](https://github.com/TheAlgorithms/Python/blob/master/matrix/tests/test_matrix_operation.py) -## [Monkeytype Config](https://github.com/TheAlgorithms/Python/blob/master//monkeytype_config.py) - ## Networking Flow * [Ford Fulkerson](https://github.com/TheAlgorithms/Python/blob/master/networking_flow/ford_fulkerson.py) * [Minimum Cut](https://github.com/TheAlgorithms/Python/blob/master/networking_flow/minimum_cut.py) From 3e6fcdc49983683a2dcdb9bc966d71ab84b738cb Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 28 Mar 2021 14:13:28 +0200 Subject: [PATCH 26/33] Apply pyannotate suggestions to emails_from_url.py --- web_programming/emails_from_url.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web_programming/emails_from_url.py b/web_programming/emails_from_url.py index 0757ae6895e5..128ff6991e0a 100644 --- a/web_programming/emails_from_url.py +++ b/web_programming/emails_from_url.py @@ -14,12 +14,12 @@ class Parser(HTMLParser): - def __init__(self, domain: str): + def __init__(self, domain: str) -> None: HTMLParser.__init__(self) self.data = [] self.domain = domain - def handle_starttag(self, tag: str, attrs: str) -> None: + def handle_starttag(self, tag: str, attrs: list[tuple[str, str]]) -> None: """ This function parse html to take takes url from tags """ @@ -59,7 +59,7 @@ def get_sub_domain_name(url: str) -> str: return parse.urlparse(url).netloc -def emails_from_url(url: str = "https://github.com") -> list: +def emails_from_url(url: str = "https://github.com") -> list[str]: """ This function takes url and return all valid urls """ From b36d324bb1a9e89615606149fe080df254218234 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 28 Mar 2021 14:14:35 +0200 Subject: [PATCH 27/33] mypy web_programming/emails_from_url.py --- .github/workflows/monkeytype.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/monkeytype.yml b/.github/workflows/monkeytype.yml index ee2bfa9e388f..5bc5fcc842f2 100644 --- a/.github/workflows/monkeytype.yml +++ b/.github/workflows/monkeytype.yml @@ -18,6 +18,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip setuptools wheel - python -m pip install pyannotate pytest -r requirements.txt + python -m pip install mypy pyannotate pytest -r requirements.txt - run: python3 web_programming/emails_from_url.py - run: cat type_info.json || true + - run: mypy web_programming/emails_from_url.py From b3a99d8619e94824689d33d6f2c8fecdae356dc6 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 28 Mar 2021 14:29:13 +0200 Subject: [PATCH 28/33] super().__init__() --- web_programming/emails_from_url.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/web_programming/emails_from_url.py b/web_programming/emails_from_url.py index 128ff6991e0a..dc3f3b2a49ce 100644 --- a/web_programming/emails_from_url.py +++ b/web_programming/emails_from_url.py @@ -8,6 +8,7 @@ import re from html.parser import HTMLParser +from typing import Optional from urllib import parse import requests @@ -15,11 +16,11 @@ class Parser(HTMLParser): def __init__(self, domain: str) -> None: - HTMLParser.__init__(self) + super().__init__() self.data = [] self.domain = domain - def handle_starttag(self, tag: str, attrs: list[tuple[str, str]]) -> None: + def handle_starttag(self, tag: str, attrs: list[tuple[str, Optional[str]]]) -> None: """ This function parse html to take takes url from tags """ From 7c01695838f82e718b5b07105cd23705e6c469c0 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 28 Mar 2021 14:39:22 +0200 Subject: [PATCH 29/33] mypy --ignore-missing-imports web_programming/emails_from_url.py --- .github/workflows/monkeytype.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/monkeytype.yml b/.github/workflows/monkeytype.yml index 5bc5fcc842f2..cb5c456e1400 100644 --- a/.github/workflows/monkeytype.yml +++ b/.github/workflows/monkeytype.yml @@ -21,4 +21,4 @@ jobs: python -m pip install mypy pyannotate pytest -r requirements.txt - run: python3 web_programming/emails_from_url.py - run: cat type_info.json || true - - run: mypy web_programming/emails_from_url.py + - run: mypy --ignore-missing-imports web_programming/emails_from_url.py From 92caa166e11c1c42c079c1927a891c882b21aa04 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 28 Mar 2021 14:40:31 +0200 Subject: [PATCH 30/33] Update emails_from_url.py --- web_programming/emails_from_url.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_programming/emails_from_url.py b/web_programming/emails_from_url.py index dc3f3b2a49ce..6407fe14763e 100644 --- a/web_programming/emails_from_url.py +++ b/web_programming/emails_from_url.py @@ -17,7 +17,7 @@ class Parser(HTMLParser): def __init__(self, domain: str) -> None: super().__init__() - self.data = [] + self.data list[str] = [] self.domain = domain def handle_starttag(self, tag: str, attrs: list[tuple[str, Optional[str]]]) -> None: From aabeb4cbaea42940a2040e2bb432e6a9d6c73cca Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 28 Mar 2021 14:45:27 +0200 Subject: [PATCH 31/33] self.urls: list[str] = [] --- web_programming/emails_from_url.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/web_programming/emails_from_url.py b/web_programming/emails_from_url.py index 6407fe14763e..0571ac3313a3 100644 --- a/web_programming/emails_from_url.py +++ b/web_programming/emails_from_url.py @@ -17,7 +17,7 @@ class Parser(HTMLParser): def __init__(self, domain: str) -> None: super().__init__() - self.data list[str] = [] + self.urls: list[str] = [] self.domain = domain def handle_starttag(self, tag: str, attrs: list[tuple[str, Optional[str]]]) -> None: @@ -30,10 +30,10 @@ def handle_starttag(self, tag: str, attrs: list[tuple[str, Optional[str]]]) -> N for name, value in attrs: # If href is defined, and not empty nor # print it. if name == "href" and value != "#" and value != "": - # If not already in data. - if value not in self.data: + # If not already in urls. + if value not in self.urls: url = parse.urljoin(self.domain, value) - self.data.append(url) + self.urls.append(url) # Get main domain name (example.com) @@ -79,7 +79,7 @@ def emails_from_url(url: str = "https://github.com") -> list[str]: # Get links and loop through valid_emails = set() - for link in parser.data: + for link in parser.urls: # open URL. # read = requests.get(link) try: @@ -99,10 +99,6 @@ def emails_from_url(url: str = "https://github.com") -> list[str]: if __name__ == "__main__": - from pyannotate_runtime import collect_types - collect_types.init_types_collection() - with collect_types.collect(): - emails = emails_from_url("https://github.com") - print(f"{len(emails)} emails found:") - print("\n".join(sorted(emails))) - collect_types.dump_stats('type_info.json') + emails = emails_from_url("https://github.com") + print(f"{len(emails)} emails found:") + print("\n".join(sorted(emails))) From e3f37495d61ca6f91a84ce836204161b968fa66f Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 28 Mar 2021 14:49:57 +0200 Subject: [PATCH 32/33] mypy: Fix web_programming directory --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7273119302e2..4b4ad4cd1c87 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,6 +44,7 @@ jobs: quantum scheduling sorts + web_programming - name: Run tests run: pytest --doctest-modules --ignore=project_euler/ --ignore=scripts/ --cov-report=term-missing:skip-covered --cov=. . - if: ${{ success() }} From 6d7fd3a047ef1e17bb70583dc1ba52cbc3a7333e Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 28 Mar 2021 14:50:40 +0200 Subject: [PATCH 33/33] Delete monkeytype.yml --- .github/workflows/monkeytype.yml | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 .github/workflows/monkeytype.yml diff --git a/.github/workflows/monkeytype.yml b/.github/workflows/monkeytype.yml deleted file mode 100644 index cb5c456e1400..000000000000 --- a/.github/workflows/monkeytype.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: monkeytype - -on: - pull_request: - -jobs: - monkeytype: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - - run: which python3 || true - - run: whereis python3 || true - - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip setuptools wheel - python -m pip install mypy pyannotate pytest -r requirements.txt - - run: python3 web_programming/emails_from_url.py - - run: cat type_info.json || true - - run: mypy --ignore-missing-imports web_programming/emails_from_url.py