Skip to content

Commit e24511d

Browse files
authored
fix: support Path for envdir (#932)
1 parent a74da2c commit e24511d

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

nox/_option_set.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import argparse
2222
import collections
2323
import functools
24+
import os
2425
from argparse import ArgumentError, ArgumentParser, Namespace
2526
from collections.abc import Callable, Iterable
2627
from typing import TYPE_CHECKING, Any, Literal
@@ -47,6 +48,7 @@ def __dir__() -> list[str]:
4748

4849

4950
av_opt_str = av.optional(av.instance_of(str))
51+
av_opt_path = av.optional(av.or_(av.instance_of(str), av.instance_of(os.PathLike)))
5052
av_opt_list_str = av.optional(
5153
av.deep_iterable(
5254
member_validator=av.instance_of(str),
@@ -59,7 +61,7 @@ def __dir__() -> list[str]:
5961
@attrs.define(slots=True, kw_only=True)
6062
class NoxOptions:
6163
default_venv_backend: None | str = attrs.field(validator=av_opt_str)
62-
envdir: None | str = attrs.field(validator=av_opt_str)
64+
envdir: None | str | os.PathLike[str] = attrs.field(validator=av_opt_path)
6365
error_on_external_run: bool = attrs.field(validator=av_bool)
6466
error_on_missing_interpreters: bool = attrs.field(validator=av_bool)
6567
force_venv_backend: None | str = attrs.field(validator=av_opt_str)

nox/_options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def _envdir_merge_func(
157157
noxfile_Args (NoxOptions): The options specified in the
158158
Noxfile.
159159
"""
160-
return command_args.envdir or noxfile_args.envdir or ".nox"
160+
return os.fspath(command_args.envdir or noxfile_args.envdir or ".nox")
161161

162162

163163
def _reuse_venv_merge_func(

tests/test__option_set.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,6 @@ def test_validation_options(self) -> None:
154154
options.sessions = ("testytest",)
155155
with pytest.raises(ValueError): # noqa: PT011
156156
options.sessions = "testytest"
157+
158+
options.envdir = "envdir"
159+
options.envdir = Path("envdir")

0 commit comments

Comments
 (0)