Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repos:
- id: auto-walrus

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.9
rev: v0.12.10
hooks:
- id: ruff-check
- id: ruff-format
Expand Down Expand Up @@ -47,7 +47,7 @@ repos:
- id: validate-pyproject

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.15.0
rev: v1.17.1
hooks:
- id: mypy
args:
Expand Down
2 changes: 1 addition & 1 deletion dynamic_programming/word_break.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def is_breakable(index: int) -> bool:
if index == len_string:
return True

trie_node = trie
trie_node: Any = trie
for i in range(index, len_string):
trie_node = trie_node.get(string[i], None)

Expand Down
12 changes: 7 additions & 5 deletions web_programming/covid_stats_via_xpath.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
This is to show simple COVID19 info fetching from worldometers site using lxml
This is to show simple COVID19 info fetching from worldometers archive site using lxml
* The main motivation to use lxml in place of bs4 is that it is faster and therefore
more convenient to use in Python web projects (e.g. Django or Flask-based)
"""
Expand All @@ -19,12 +19,14 @@


class CovidData(NamedTuple):
cases: int
deaths: int
recovered: int
cases: str
deaths: str
recovered: str


def covid_stats(url: str = "https://www.worldometers.info/coronavirus/") -> CovidData:
def covid_stats(
url: str = "https://web.archive.org/web/20250825095350/https://www.worldometers.info/coronavirus/",
) -> CovidData:
xpath_str = '//div[@class = "maincounter-number"]/span/text()'
return CovidData(
*html.fromstring(httpx.get(url, timeout=10).content).xpath(xpath_str)
Expand Down