Skip to content

Commit

Permalink
chore: minor cleanups from #361
Browse files Browse the repository at this point in the history
Co-authored-by: layday <layday@protonmail.com>

Apply suggestions from code review

tests: add test for coverage
  • Loading branch information
henryiii authored and layday committed May 13, 2022
1 parent 91c7a75 commit 0c191b4
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Expand Up @@ -29,5 +29,5 @@ jobs:
- name: Setup run environment
run: tox -vv --notest -e docs

- name: Run check for type
- name: Run check for docs
run: tox -e docs --skip-pkg-install
6 changes: 5 additions & 1 deletion .readthedocs.yml
@@ -1,7 +1,11 @@
version: 2

build:
os: ubuntu-20.04
tools:
python: '3.10'

python:
version: 3.8
install:
- method: pip
path: .
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Expand Up @@ -64,7 +64,7 @@ test =
typing =
importlib-metadata>=4.6.4
mypy==0.942
typing-extensions>=3.7.4.3
typing-extensions>=3.7.4.3;python_version < "3.8"
virtualenv =
virtualenv>=20.0.35

Expand Down
29 changes: 18 additions & 11 deletions src/build/__init__.py
Expand Up @@ -3,6 +3,7 @@
"""
build - A simple, correct PEP 517 build frontend
"""

__version__ = '0.7.0'

import contextlib
Expand All @@ -24,6 +25,7 @@
Callable,
Dict,
Iterator,
List,
Mapping,
MutableMapping,
Optional,
Expand Down Expand Up @@ -71,18 +73,18 @@
}


_logger = logging.getLogger('build')
_logger = logging.getLogger(__name__)


class BuildException(Exception):
"""
Exception raised by ProjectBuilder
Exception raised by :class:`ProjectBuilder`
"""


class BuildBackendException(Exception):
"""
Exception raised when the backend fails
Exception raised when a backend operation fails
"""

def __init__(
Expand Down Expand Up @@ -131,7 +133,7 @@ def __str__(self) -> str:

class TypoWarning(Warning):
"""
Warning raised when a potential typo is found
Warning raised when a possible typo is found
"""


Expand Down Expand Up @@ -428,12 +430,13 @@ def build(

def metadata_path(self, output_directory: PathType) -> str:
"""
Generates the metadata directory of a distribution and returns its path.
Generate the metadata directory of a distribution and return its path.
If the backend does not support the ``prepare_metadata_for_build_wheel``
hook, a wheel will be built and the metadata extracted.
hook, a wheel will be built and the metadata will be extracted from it.
:param output_directory: Directory to put the metadata distribution in
:returns: The path of the metadata directory
"""
# prepare_metadata hook
metadata = self.prepare('wheel', output_directory)
Expand Down Expand Up @@ -491,20 +494,20 @@ def _handle_backend(self, hook: str) -> Iterator[None]:
@staticmethod
def log(message: str) -> None:
"""
Prints message
Log a message.
The default implementation uses the logging module but this function can be
overwritten by users to have a different implementation.
overridden by users to have a different implementation.
:param msg: Message to output
:param message: Message to output
"""
if sys.version_info >= (3, 8):
_logger.log(logging.INFO, message, stacklevel=2)
else:
_logger.log(logging.INFO, message)


__all__ = (
__all__ = [
'__version__',
'BuildBackendException',
'BuildException',
Expand All @@ -514,4 +517,8 @@ def log(message: str) -> None:
'RunnerType',
'TypoWarning',
'check_dependency',
)
]


def __dir__() -> List[str]:
return __all__
2 changes: 1 addition & 1 deletion src/build/__main__.py
Expand Up @@ -79,7 +79,7 @@ def _error(msg: str, code: int = 1) -> NoReturn: # pragma: no cover
:param code: Error code
"""
print('{red}ERROR{reset} {}'.format(msg, **_STYLES))
exit(code)
raise SystemExit(code)


class _ProjectBuilder(ProjectBuilder):
Expand Down
9 changes: 9 additions & 0 deletions tests/test_module.py
@@ -1,7 +1,16 @@
# SPDX-License-Identifier: MIT

import sys

import pytest

import build


def test_version():
assert build.__version__


@pytest.mark.skipif(sys.version_info < (3, 7), reason='Python 3.7+ required for dir support')
def test_dir():
assert set(dir(build)) == set(build.__all__)

0 comments on commit 0c191b4

Please sign in to comment.