Skip to content

Commit

Permalink
Merge branch 'main' into henryiii/feat/mamba
Browse files Browse the repository at this point in the history
  • Loading branch information
henryiii committed Sep 17, 2021
2 parents e0d650a + f584aed commit 847acb5
Show file tree
Hide file tree
Showing 27 changed files with 595 additions and 275 deletions.
29 changes: 22 additions & 7 deletions .github/workflows/ci.yml
Expand Up @@ -23,6 +23,27 @@ jobs:
python -m pip install --disable-pip-version-check .
- name: Run tests on ${{ matrix.os }}
run: nox --non-interactive --session "tests-${{ matrix.python-version }}" -- --full-trace

build-py310:
name: Build python 3.10
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-2019]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: "3.10.0-rc.2"
# Conda does not support 3.10 yet, hence why it's skipped here
# TODO: Merge the two build jobs when 3.10 is released for conda
- name: Install Nox-under-test
run: |
python -m pip install --disable-pip-version-check .
- name: Run tests on ${{ matrix.os }}
run: nox --non-interactive --session "tests-3.10" -- --full-trace

lint:
runs-on: ubuntu-20.04
steps:
Expand Down Expand Up @@ -55,14 +76,8 @@ jobs:
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install setuptools and wheel
run: python -m pip install --upgrade --user setuptools wheel
- name: Build sdist and wheel
run: python setup.py sdist bdist_wheel
run: pipx run build
- name: Publish distribution PyPI
uses: pypa/gh-action-pypi-publish@master
with:
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,12 @@
# Changelog

## 2021.6.12

- Fix crash on Python 2 when reusing environments. (#450)
- Hide staleness check behind a feature flag. (#451)
- Group command-line options in `--help` message by function. (#442)
- Avoid polluting tests with a .nox directory. (#445)

## 2021.6.6

- Add option `--no-install` to skip install commands in reused environments. (#432)
Expand Down
10 changes: 8 additions & 2 deletions docs/index.rst
Expand Up @@ -51,17 +51,23 @@ Projects that use Nox
Nox is lucky to have several wonderful projects that use it and provide feedback and contributions.

- `Bézier <https://github.com/dhermes/bezier>`__
- `cibuildwheel <https://github.com/pypa/cibuildwheel>`__
- `gapic-generator-python <https://github.com/googleapis/gapic-generator-python>`__
- `gdbgui <https://github.com/cs01/gdbgui>`__
- `Google Assistant SDK <https://github.com/googlesamples/assistant-sdk-python>`__
- `google-cloud-python <https://github.com/googlecloudplatform/google-cloud-python>`__
- `google-resumable-media-python <https://github.com/GoogleCloudPlatform/google-resumable-media-python>`__
- `Hydra <https://hydra.cc>`__
- `manylinux <https://github.com/pypa/manylinux>`__
- `OmegaConf <https://github.com/omry/omegaconf>`__
- `OpenCensus Python <https://github.com/census-instrumentation/opencensus-python>`__
- `packaging.python.org <https://github.com/pypa/python-packaging-user-guide/>`__
- `pipx <https://github.com/pipxproject/pipx/>`__
- `packaging <https://github.com/pypa/packaging>`__
- `packaging.python.org <https://github.com/pypa/python-packaging-user-guide>`__
- `pip <https://github.com/pypa/pip>`__
- `pipx <https://github.com/pypa/pipx>`__
- `Salt <https://github.com/saltstack/salt>`__
- `Scikit-build <https://github.com/scikit-build/scikit-build>`__
- `Scikit-HEP <https://scikit-hep.org/developer/tasks>`__
- `Subpar <https://github.com/google/subpar>`__
- `Urllib3 <https://github.com/urllib3/urllib3>`__
- `Zazo <https://github.com/pradyunsg/zazo>`__
Expand Down
8 changes: 4 additions & 4 deletions nox/_decorators.py
Expand Up @@ -18,7 +18,7 @@ def __new__(
return cast("FunctionDecorator", functools.wraps(func)(obj))


def _copy_func(src: Callable, name: str = None) -> Callable:
def _copy_func(src: Callable, name: Optional[str] = None) -> Callable:
dst = types.FunctionType(
src.__code__,
src.__globals__, # type: ignore
Expand All @@ -41,7 +41,7 @@ def __init__(
name: Optional[str] = None,
venv_backend: Any = None,
venv_params: Any = None,
should_warn: Dict[str, Any] = None,
should_warn: Optional[Dict[str, Any]] = None,
):
self.func = func
self.python = python
Expand All @@ -53,7 +53,7 @@ def __init__(
def __call__(self, *args: Any, **kwargs: Any) -> Any:
return self.func(*args, **kwargs)

def copy(self, name: str = None) -> "Func":
def copy(self, name: Optional[str] = None) -> "Func":
return Func(
_copy_func(self.func, name),
self.python,
Expand All @@ -68,7 +68,7 @@ def copy(self, name: str = None) -> "Func":
class Call(Func):
def __init__(self, func: Func, param_spec: "Param") -> None:
call_spec = param_spec.call_spec
session_signature = "({})".format(param_spec)
session_signature = f"({param_spec})"

# Determine the Python interpreter for the session using either @session
# or @parametrize. For backwards compatibility, we only use a "python"
Expand Down
27 changes: 16 additions & 11 deletions nox/_option_set.py
Expand Up @@ -20,7 +20,8 @@
import argparse
import collections
import functools
from argparse import ArgumentError, ArgumentParser, Namespace
from argparse import ArgumentError as ArgumentError
from argparse import ArgumentParser, Namespace
from typing import Any, Callable, List, Optional, Tuple, Union

import argcomplete
Expand Down Expand Up @@ -76,15 +77,15 @@ def __init__(
self,
name: str,
*flags: str,
group: OptionGroup,
group: Optional[OptionGroup],
help: Optional[str] = None,
noxfile: bool = False,
merge_func: Optional[Callable[[Namespace, Namespace], Any]] = None,
finalizer_func: Optional[Callable[[Any, Namespace], Any]] = None,
default: Union[Any, Callable[[], Any]] = None,
hidden: bool = False,
completer: Optional[Callable[..., List[str]]] = None,
**kwargs: Any
**kwargs: Any,
) -> None:
self.name = name
self.flags = flags
Expand Down Expand Up @@ -155,27 +156,25 @@ def make_flag_pair(
name: str,
enable_flags: Union[Tuple[str, str], Tuple[str]],
disable_flags: Tuple[str],
**kwargs: Any
**kwargs: Any,
) -> Tuple[Option, Option]:
"""Returns two options - one to enable a behavior and another to disable it.
The positive option is considered to be available to the noxfile, as
there isn't much point in doing flag pairs without it.
"""
disable_name = "no_{}".format(name)
disable_name = f"no_{name}"

kwargs["action"] = "store_true"
enable_option = Option(
name,
*enable_flags,
noxfile=True,
merge_func=functools.partial(flag_pair_merge_func, name, disable_name),
**kwargs
**kwargs,
)

kwargs["help"] = "Disables {} if it is enabled in the Noxfile.".format(
enable_flags[-1]
)
kwargs["help"] = f"Disables {enable_flags[-1]} if it is enabled in the Noxfile."
disable_option = Option(disable_name, *disable_flags, **kwargs)

return enable_option, disable_option
Expand Down Expand Up @@ -231,9 +230,15 @@ def parser(self) -> ArgumentParser:
}

for option in self.options.values():
if option.hidden:
if option.hidden is True:
continue

# Every option must have a group (except for hidden options)
if option.group is None:
raise ValueError(
f"Option {option.name} must either have a group or be hidden."
)

argument = groups[option.group.name].add_argument(
*option.flags, help=option.help, default=option.default, **option.kwargs
)
Expand Down Expand Up @@ -284,7 +289,7 @@ def namespace(self, **kwargs: Any) -> argparse.Namespace:
# used in tests.
for key, value in kwargs.items():
if key not in args:
raise KeyError("{} is not an option.".format(key))
raise KeyError(f"{key} is not an option.")
args[key] = value

return argparse.Namespace(**args)
Expand Down

0 comments on commit 847acb5

Please sign in to comment.