Skip to content

Commit

Permalink
chore: update cruft
Browse files Browse the repository at this point in the history
  • Loading branch information
wpk-nist-gov committed Feb 18, 2025
1 parent 14868f1 commit ae6936e
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 41 deletions.
4 changes: 2 additions & 2 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"template": "https://github.com/usnistgov/cookiecutter-nist-python.git",
"commit": "ce1bec36acf76cc95cb3f865f059b8804fea4b7a",
"commit": "ea1b44f9306f1965ccf3b8cdf83ef9ad8a9dbd83",
"checkout": "develop",
"context": {
"cookiecutter": {
Expand All @@ -19,7 +19,7 @@
"__answers": "",
"_copy_without_render": [],
"_template": "https://github.com/usnistgov/cookiecutter-nist-python.git",
"_commit": "ce1bec36acf76cc95cb3f865f059b8804fea4b7a"
"_commit": "ea1b44f9306f1965ccf3b8cdf83ef9ad8a9dbd83"
}
},
"directory": null
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ repos:

# * Prettier
- repo: https://github.com/rbubley/mirrors-prettier
rev: v3.5.0
rev: v3.5.1
hooks:
- id: prettier
alias: markdownlint
Expand Down Expand Up @@ -99,7 +99,7 @@ repos:
# * uv
- repo: https://github.com/astral-sh/uv-pre-commit
# uv version.
rev: 0.5.30
rev: 0.6.0
hooks:
- id: uv-lock
args: [--locked]
Expand All @@ -121,7 +121,7 @@ repos:
language: python
files: ^requirements/.*\.txt$
pass_filenames: false
additional_dependencies: ["nox==2024.10.9"]
additional_dependencies: ["nox==2025.2.9"]

# * Manual Linting ------------------------------------------------------------
# - repo: https://github.com/asottile/pyupgrade
Expand Down Expand Up @@ -156,7 +156,7 @@ repos:
# ** typos
# Probably stick with codespell, but this might also be nice...
- repo: https://github.com/crate-ci/typos
rev: typos-dict-v0.12.4
rev: typos-dict-v0.12.5
hooks:
- id: typos
stages: [manual]
Expand Down
14 changes: 14 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"sphinx_copybutton",
"myst_parser",
"sphinx_click",
"sphinx_autodoc_typehints",
]

autosectionlabel_prefix_document = True
Expand All @@ -57,6 +58,7 @@
nitpick_ignore = [
("py:class", "Command"),
("py:class", "typer.core.TyperGroup"),
("py:class", "Requirement"),
]

# -- myst stuff ---------------------------------------------------------
Expand Down Expand Up @@ -143,8 +145,18 @@
"private-members",
"show-inheritance",
]
# autodoc_typehints = "signature"
autodoc_typehints = "none"

autodoc_type_aliases = {"Self": "Self"}

typehints_document_rtype = False
typehints_use_rtype = False
typehints_defaults = "comma"
# always_document_param_types = True
typehints_use_signature = True
typehints_use_signature_return = True

# -- napoleon ------------------------------------------------------------------
napoleon_google_docstring = False
napoleon_numpy_docstring = True
Expand Down Expand Up @@ -408,6 +420,8 @@ def _get_ipython_savefig_dir() -> str:
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
"python": ("https://docs.python.org/3/", None),
"click": ("https://click.palletsprojects.com/en/stable/", None),
"packaging": ("https://packaging.pypa.io/en/stable/", None),
# "pandas": ("https://pandas.pydata.org/pandas-docs/stable", None),
# "numpy": ("https://numpy.org/doc/stable", None),
# "scipy": ("https://docs.scipy.org/doc/scipy/", None),
Expand Down
11 changes: 8 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,9 @@ class SessionParams(DataclassParser):
| None
) = add_option("--docs", "-d", help="doc commands")
docs_run: RUN_ANNO = None

docs_options: OPT_TYPE = add_option(
"--docs-options", help="Options to sphinx-build"
)
# lint
lint_options: OPT_TYPE = add_option(help="Options to pre-commit")

Expand Down Expand Up @@ -508,7 +510,7 @@ def lock(
"--universal",
f"--config-file={PIP_COMPILE_CONFIG}",
"-q",
"-p",
"--python-version",
python_version,
*options,
path,
Expand Down Expand Up @@ -711,7 +713,10 @@ def docs( # noqa: C901, PLR0912
cmd.remove("serve")

if cmd:
common_opts = ["--doctree-dir=docs/_build/doctree"]
common_opts = [
"--doctree-dir=docs/_build/doctree",
*(opts.docs_options or ()),
]
for c in combine_list_str(cmd):
if c == "clean":
for d in ("docs/_build", "generated", "reference/generated"):
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ docs = [
"myst-parser",
"pyenchant",
"sphinx>=5.3.0",
"sphinx-autodoc-typehints",
"sphinx-book-theme",
"sphinx-click",
"sphinx-copybutton",
Expand Down
8 changes: 4 additions & 4 deletions requirements/lock/py312-uvxrun-tools.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file was autogenerated by uv via the following command:
# uv pip compile --universal --config-file=requirements/uv.toml -p 3.12 requirements/uvxrun-tools.txt -o requirements/lock/py312-uvxrun-tools.txt
# uv pip compile --universal --config-file=requirements/uv.toml --python-version 3.12 requirements/uvxrun-tools.txt -o requirements/lock/py312-uvxrun-tools.txt
annotated-types==0.7.0 \
--hash=sha256:1f02e8b43a8fbbc3f3e0d4f0f4bfc8131bcb4eebe8849b8e5c773f3a1c582a53 \
--hash=sha256:aff07c09a53a08bc8cfccb9c85b05f1aa9a2a6f23728d790723543408344ce89
Expand Down Expand Up @@ -739,9 +739,9 @@ pylev==1.4.0 \
--hash=sha256:7b2e2aa7b00e05bb3f7650eb506fc89f474f70493271a35c242d9a92188ad3dd \
--hash=sha256:9e77e941042ad3a4cc305dcdf2b2dec1aec2fbe3dd9015d2698ad02b173006d1
# via clikit
pyright==1.1.393 \
--hash=sha256:8320629bb7a44ca90944ba599390162bf59307f3d9fb6e27da3b7011b8c17ae5 \
--hash=sha256:aeeb7ff4e0364775ef416a80111613f91a05c8e01e58ecfefc370ca0db7aed9c
pyright==1.1.394 \
--hash=sha256:56f2a3ab88c5214a451eb71d8f2792b7700434f841ea219119ade7f42ca93608 \
--hash=sha256:5f74cce0a795a295fb768759bbeeec62561215dea657edcaab48a932b031ddbb
# via -r requirements/uvxrun-tools.txt
python-utils==3.9.1 \
--hash=sha256:0273d7363c7ad4b70999b2791d5ba6b55333d6f7a4e4c8b6b39fb82b5fab4613 \
Expand Down
13 changes: 8 additions & 5 deletions src/pyproject2conda/_typing.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
from __future__ import annotations

from typing import TYPE_CHECKING, Literal, TypeVar
from typing import TYPE_CHECKING, TypeVar

R = TypeVar("R")
T = TypeVar("T")


if TYPE_CHECKING:
from typing import Literal # noqa: F401

from packaging.requirements import (
Requirement, # pyright: ignore[reportUnusedImport] # noqa: F401
)

from ._typing_compat import TypeAlias
from .overrides import (
OverrideDeps, # pyright: ignore[reportUnusedImport] # noqa: F401
)
from .utils import _Missing # pyright: ignore[reportPrivateUsage]
from .utils import _Missing # pyright: ignore[reportPrivateUsage] # noqa: F401

MISSING_TYPE = Literal[_Missing.MISSING]
MISSING_TYPE: TypeAlias = "Literal[_Missing.MISSING]"

RequirementCommentPair = "tuple[Requirement | None, str | None]"
RequirementOverridePair = "tuple[Requirement | None, OverrideDeps | None]"
RequirementCommentPair: TypeAlias = "tuple[Requirement | None, str | None]"
RequirementOverridePair: TypeAlias = "tuple[Requirement | None, OverrideDeps | None]"
16 changes: 8 additions & 8 deletions src/pyproject2conda/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class AliasedGroup(TyperGroup):

def get_command( # noqa: D102
self, ctx: click.Context, cmd_name: str
) -> Optional[click.core.Command]:
) -> Optional[click.Command]:
if (rv := super().get_command(ctx, cmd_name)) is not None:
return rv
if not (
Expand Down Expand Up @@ -479,7 +479,7 @@ def _log_creating(
logger.info(s)


def add_verbose_logger(
def _add_verbose_logger(
logger: logging.Logger, verbose_arg: str = "verbose"
) -> Callable[[Callable[..., R]], Callable[..., R]]:
"""Decorator factory to add logger and set logger level based on verbosity argument value."""
Expand Down Expand Up @@ -525,7 +525,7 @@ def wrapped(*args: Any, **kwargs: Any) -> R:
# ** List
# @app_typer.command("l", hidden=True)
@app_typer.command("list")
@add_verbose_logger(logger)
@_add_verbose_logger(logger)
def create_list(
filename: PYPROJECT_CLI = DEFAULT_TOML_PATH,
verbose: VERBOSE_CLI = None, # noqa: ARG001
Expand All @@ -545,7 +545,7 @@ def create_list(
# ** Yaml
# @app_typer.command("y", hidden=True)
@app_typer.command()
@add_verbose_logger(logger)
@_add_verbose_logger(logger)
def yaml(
filename: PYPROJECT_CLI = DEFAULT_TOML_PATH,
extras: EXTRAS_CLI = None,
Expand Down Expand Up @@ -613,7 +613,7 @@ def yaml(
# ** Requirements
# @app_typer.command("r", hidden=True)
@app_typer.command()
@add_verbose_logger(logger)
@_add_verbose_logger(logger)
def requirements(
filename: PYPROJECT_CLI = DEFAULT_TOML_PATH,
extras: EXTRAS_CLI = None,
Expand Down Expand Up @@ -660,7 +660,7 @@ def requirements(

# @app_typer.command("p", hidden=True)
@app_typer.command()
@add_verbose_logger(logger)
@_add_verbose_logger(logger)
def project(
filename: PYPROJECT_CLI = DEFAULT_TOML_PATH,
envs: ENVS_CLI = None,
Expand Down Expand Up @@ -738,7 +738,7 @@ def project(

# @app_typer.command("cr", hidden=True)
@app_typer.command()
@add_verbose_logger(logger)
@_add_verbose_logger(logger)
def conda_requirements(
path_conda: Annotated[Optional[str], typer.Argument()] = None,
path_pip: Annotated[Optional[str], typer.Argument()] = None,
Expand Down Expand Up @@ -815,7 +815,7 @@ def conda_requirements(
# ** json
# @app_typer.command("j", hidden=True)
@app_typer.command("json")
@add_verbose_logger(logger)
@_add_verbose_logger(logger)
def to_json(
extras: EXTRAS_CLI = None,
groups: GROUPS_CLI = None,
Expand Down
3 changes: 2 additions & 1 deletion src/pyproject2conda/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ def _update_requirement( # noqa: C901

# ** Dependencices
def resolve_extras(
*,
extras: str | Iterable[str],
package_name: str,
unresolved: dict[str, list[Requirement]],
Expand Down Expand Up @@ -399,7 +400,7 @@ def requirements_extras(self) -> dict[str, list[Requirement]]:

resolved = {
extra: resolve_extras(
extra, package_name=self.package_name, unresolved=unresolved
extras=extra, package_name=self.package_name, unresolved=unresolved
)
for extra in unresolved
}
Expand Down
Loading

0 comments on commit ae6936e

Please sign in to comment.