[pre-commit.ci] pre-commit autoupdate (#12930)

* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.12.9 → v0.12.10](https://github.com/astral-sh/ruff-pre-commit/compare/v0.12.9...v0.12.10)
- [github.com/pre-commit/mirrors-mypy: v1.15.0 → v1.17.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.15.0...v1.17.1)

* Update word_break.py

* Update word_break.py

* Update word_break.py

* Update word_break.py

* Update word_break.py

* Update covid_stats_via_xpath.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update pyproject.toml

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update pyproject.toml

* Update pyproject.toml

* Update covid_stats_via_xpath.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
This commit is contained in:
pre-commit-ci[bot]
2025-08-26 15:32:39 +03:00
committed by GitHub
parent 8c1c6c1763
commit dc1b2003b4
3 changed files with 10 additions and 8 deletions

View File

@@ -16,7 +16,7 @@ repos:
- id: auto-walrus - id: auto-walrus
- repo: https://github.com/astral-sh/ruff-pre-commit - repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.9 rev: v0.12.10
hooks: hooks:
- id: ruff-check - id: ruff-check
- id: ruff-format - id: ruff-format
@@ -47,7 +47,7 @@ repos:
- id: validate-pyproject - id: validate-pyproject
- repo: https://github.com/pre-commit/mirrors-mypy - repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.15.0 rev: v1.17.1
hooks: hooks:
- id: mypy - id: mypy
args: args:

View File

@@ -90,7 +90,7 @@ def word_break(string: str, words: list[str]) -> bool:
if index == len_string: if index == len_string:
return True return True
trie_node = trie trie_node: Any = trie
for i in range(index, len_string): for i in range(index, len_string):
trie_node = trie_node.get(string[i], None) trie_node = trie_node.get(string[i], None)

View File

@@ -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 * 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) more convenient to use in Python web projects (e.g. Django or Flask-based)
""" """
@@ -19,12 +19,14 @@ from lxml import html
class CovidData(NamedTuple): class CovidData(NamedTuple):
cases: int cases: str
deaths: int deaths: str
recovered: int 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()' xpath_str = '//div[@class = "maincounter-number"]/span/text()'
return CovidData( return CovidData(
*html.fromstring(httpx.get(url, timeout=10).content).xpath(xpath_str) *html.fromstring(httpx.get(url, timeout=10).content).xpath(xpath_str)