Skip to content

Commit

Permalink
fix: support Path for envdir
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <[email protected]>
  • Loading branch information
henryiii committed Feb 11, 2025
1 parent a74da2c commit be0ebd7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion nox/_option_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import argparse
import collections
import functools
import os
from argparse import ArgumentError, ArgumentParser, Namespace
from collections.abc import Callable, Iterable
from typing import TYPE_CHECKING, Any, Literal
Expand All @@ -47,6 +48,7 @@ def __dir__() -> list[str]:


av_opt_str = av.optional(av.instance_of(str))
av_opt_path = av.optional(av.or_(av.instance_of(str), av.instance_of(os.PathLike)))
av_opt_list_str = av.optional(
av.deep_iterable(
member_validator=av.instance_of(str),
Expand All @@ -59,7 +61,7 @@ def __dir__() -> list[str]:
@attrs.define(slots=True, kw_only=True)
class NoxOptions:
default_venv_backend: None | str = attrs.field(validator=av_opt_str)
envdir: None | str = attrs.field(validator=av_opt_str)
envdir: None | str | os.PathLike[str] = attrs.field(validator=av_opt_path)
error_on_external_run: bool = attrs.field(validator=av_bool)
error_on_missing_interpreters: bool = attrs.field(validator=av_bool)
force_venv_backend: None | str = attrs.field(validator=av_opt_str)
Expand Down
2 changes: 1 addition & 1 deletion nox/_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def _envdir_merge_func(
noxfile_Args (NoxOptions): The options specified in the
Noxfile.
"""
return command_args.envdir or noxfile_args.envdir or ".nox"
return os.fspath(command_args.envdir or noxfile_args.envdir or ".nox")


def _reuse_venv_merge_func(
Expand Down
3 changes: 3 additions & 0 deletions tests/test__option_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,6 @@ def test_validation_options(self) -> None:
options.sessions = ("testytest",)
with pytest.raises(ValueError): # noqa: PT011
options.sessions = "testytest"

options.envdir = "envdir"
options.envdir = Path("envdir")

0 comments on commit be0ebd7

Please sign in to comment.