Skip to content

Commit

Permalink
rm marshmallow, desert
Browse files Browse the repository at this point in the history
  • Loading branch information
duksosleepy committed Jul 29, 2024
1 parent 0139231 commit db20b07
Show file tree
Hide file tree
Showing 7 changed files with 159 additions and 116 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Modern python environment

poetry, pyenv, pytest, pytest-cov, pytest-mock, nox, black, safety, pre-commit, mypy, pytype (or pyre, pyright), marshmallow, typeguard.
jsonargparse, httpx, cattrs & orjson
jsonargparse, httpx, cattrs[orjson] & orjson
sphinx, sphinx-autodoc-typehints, git actions, codecov.

And important, run in python v3.12
30 changes: 15 additions & 15 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


def install_with_constraints(
session: nox.sessions.Session, *args: str, **kwargs: Any
session: nox.Session, *args: str, **kwargs: Any
) -> None:
"""Install packages constrained by Poetry's lock file."""
session.run(
Expand All @@ -29,7 +29,7 @@ def install_with_constraints(
session.install("--constraint=requirements.txt", *args, **kwargs)


def install(session, groups, root=True):
def install(session: nox.Session, groups: list[str], root: bool = True):
if root:
groups = ["main", *groups]
session.run_install(
Expand Down Expand Up @@ -87,15 +87,15 @@ def safety(session):
"""


def constraints(session):
def constraints(session: nox.Session):
filename = f"python{session.python}-{sys.platform}-{platform.machine()}.txt"
return Path("constraints") / filename


@nox.session(
python=["3.12", "3.11", "3.10", "3.9", "3.8", "3.7"], venv_backend="uv"
)
def lock(session):
def lock(session: nox.Session):
"""Lock the dependencies."""
filename = constraints(session)
filename.parent.mkdir(exist_ok=True)
Expand All @@ -112,7 +112,7 @@ def lock(session):


@nox.session
def build(session):
def build(session: nox.Session):
"""Build the package."""
session.install("build", "twine")

Expand All @@ -125,7 +125,7 @@ def build(session):


@nox.session(python=["3.11"])
def safety(session):
def safety(session: nox.Session):
"""Scan dependencies for insecure packages."""
session.run(
"poetry",
Expand All @@ -139,7 +139,7 @@ def safety(session):
session.run("safety", "check", "--file=requirements.txt", "--full-report")


def install_coverage_pth(session):
def install_coverage_pth(session: nox.Session):
output = session.run(
"python",
"-c",
Expand All @@ -153,15 +153,15 @@ def install_coverage_pth(session):


@nox.session(python=["3.11"])
def tests(session):
def tests(session: nox.Session):
"""Run the test suite."""
args = session.posargs or ["--cov"]
session.run("poetry", "install", external=True)
session.run("pytest", *args)


@nox.session(python=["3.12", "3.11", "3.10", "3.9", "3.8", "3.7"])
def tests_2(session):
def tests_2(session: nox.Session):
"""Run the test suite."""
session.install("-c", constraints(session), ".[tests]")
install_coverage_pth(session)
Expand All @@ -174,7 +174,7 @@ def tests_2(session):


@nox.session(python="3.12")
def lint(session):
def lint(session: nox.Session):
"""Lint using pre-commit."""
options = ["--all-files", "--show-diff-on-fail"]
session.install(f"--constraint={constraints(session)}", "pre-commit")
Expand All @@ -199,7 +199,7 @@ def typeguard(session: nox.Session) -> None:


@nox.session(python=["3.11"])
def black(session):
def black(session: nox.Session):
"""Run black code formatter."""
args = session.posargs or locations
session.install(
Expand All @@ -209,15 +209,15 @@ def black(session):


@nox.session(python=["3.11"])
def pytype(session):
def pytype(session: nox.Session):
"""Type-check using pytype."""
args = session.posargs or ["--disable=import-error", *locations]
session.install("pytype")
session.run("pytype", *args)


@nox.session(python=["3.11"])
def xdoctest(session: nox.sessions.Session) -> None:
def xdoctest(session: nox.Session) -> None:
"""Run examples with xdoctest."""
args = session.posargs or ["all"]
session.run("poetry", "install", "--no-dev", external=True)
Expand All @@ -226,15 +226,15 @@ def xdoctest(session: nox.sessions.Session) -> None:


@nox.session(python=["3.11"])
def docs(session: nox.sessions.Session) -> None:
def docs(session: nox.Session) -> None:
"""Build the documentation."""
session.run("poetry", "install", "--no-dev", external=True)
session.install("sphinx", "sphinx-autodoc-typehints")
session.run("sphinx-build", "docs", "docs/_build")


@nox.session(python=["3.11"])
def coverage(session: nox.sessions.Session) -> None:
def coverage(session: nox.Session) -> None:
"""Generate the coverage report."""
session.install("-c", constraints(session), "coverage[toml]")
if any(Path().glob(".coverage.*")):
Expand Down
140 changes: 85 additions & 55 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ include = ["tests"]
[tool.poetry.dependencies]
python = "^3.12"
safety-db = "^2021.7.17"
desert = "^2022.9.22"
marshmallow = "^3.19.0"
codecov = "^2.1.13"
httpx = "^0.27.0"
jsonargparse = {extras = ["all"], version = "^4.32.0"}
loguru = "^0.7.2"
cattrs = {extras = ["orjson"], version = "^23.2.3"}


[tool.poetry.group.dev.dependencies]
Expand Down
Binary file not shown.
11 changes: 0 additions & 11 deletions src/hypermodern_python/console.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
"""Command-line interface."""

import textwrap

from prettier import cprint

from . import wikipedia


def cmd() -> None:
from jsonargparse import CLI

CLI(wikipedia.Fetcher)


def main(language: str) -> None:
"""The hypermodern Python project."""
page = wikipedia.random_page(language=language)
cprint(page.title, fg="g")
cprint(textwrap.fill(page.extract))
Loading

0 comments on commit db20b07

Please sign in to comment.