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
10 changes: 3 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,13 @@ jobs:
run: python -m pip install --upgrade -e ".[dev]"

# tests
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Lint with ruff
run: ruff check .

- name: Code format and type checking
if: ${{ matrix.python-version == env.REF_PY_VERSION }}
run: |
black --check --diff htmldate
ruff format --check htmldate
mypy -p htmldate

- name: Install full dependencies
Expand Down
27 changes: 0 additions & 27 deletions .pre-commit-config.yaml

This file was deleted.

3 changes: 1 addition & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ and if there are no errors.
2. Run the tests and code quality tools:
- Tests with `pytest`
- Type checking with `mypy` on the directory: `mypy htmldate/`
- Code formatting with `black` on the directory as well
- Optional: install `pre-commit` to use the corresponding commit hooks
- Linting with `ruff check .` and formatting with `ruff format htmldate/`


For further questions you can use [GitHub issues](https://github.com/adbar/htmldate/issues) or [E-Mail](https://adrien.barbaresi.eu/).
Expand Down
6 changes: 3 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ Htmldate: Find the Publication Date of Web Pages
:target: https://doi.org/10.21105/joss.02439
:alt: JOSS article reference DOI: 10.21105/joss.02439

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black
:alt: Code style: black
.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
:target: https://github.com/astral-sh/ruff
:alt: Ruff

|

Expand Down
17 changes: 8 additions & 9 deletions htmldate/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import sys

from platform import python_version
from typing import Any, Optional, Union

from lxml.html import HtmlElement

Expand All @@ -17,12 +16,12 @@


def cli_examine(
htmlstring: Union[str, HtmlElement],
args: Any,
) -> Optional[str]:
htmlstring: str | HtmlElement | None,
args: argparse.Namespace,
) -> str | None:
"""Generic safeguards and triggers"""
# safety check
if is_wrong_document(htmlstring):
if htmlstring is None or is_wrong_document(htmlstring):
sys.stderr.write("# ERROR: document is empty or too large\n")
return None
return find_date(
Expand All @@ -35,7 +34,7 @@ def cli_examine(
)


def parse_args(args: Any) -> Any:
def parse_args(args: list[str]) -> argparse.Namespace:
"""Define parser for command-line arguments"""
argsparser = argparse.ArgumentParser()
argsparser.add_argument(
Expand Down Expand Up @@ -67,10 +66,10 @@ def parse_args(args: Any) -> Any:
action="version",
version=f"Htmldate {__version__} - Python {python_version()}",
)
return argsparser.parse_args()
return argsparser.parse_args(args)


def process_args(args: Any) -> None:
def process_args(args: argparse.Namespace) -> None:
"""Process the arguments passed on the command-line."""
# verbosity
if args.verbose:
Expand Down Expand Up @@ -98,7 +97,7 @@ def process_args(args: Any) -> None:
with open(args.inputfile, mode="r", encoding="utf-8") as inputfile:
for line in inputfile:
htmltext = fetch_url(line.strip())
result = cli_examine(htmltext, args) # type: ignore[arg-type]
result = cli_examine(htmltext, args)
sys.stdout.write(f"{line.strip()}\t{result or 'None'}\n")


Expand Down
Loading
Loading