Skip to content

Commit

Permalink
lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cidrblock committed Aug 16, 2023
1 parent e90d0b3 commit d8ef91d
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 12 deletions.
6 changes: 6 additions & 0 deletions .config/dictionary.txt
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
bindep
bthornto
fileh
levelname
levelno
pipc
uninstallation
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ repos:
additional_dependencies:
- pytest
- tox
- pyyaml

- repo: https://github.com/pre-commit/mirrors-mypy.git
rev: v1.5.0
Expand Down
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ A pip-like install for ansible collections.
- Install all collection python requirements
- Install all collection test requirements
- Checks for missing system packages
- Symlinks the current collection into the current python intepreter's site-packages
- Install all collection collection dependencies into the current python intepreter's site-packages
- Symlinks the current collection into the current python interpreter's site-packages
- Install all collection collection dependencies into the current python interpreter's site-packages

By placing collections into the python site-packages directory they are discoverable by ansible as well as python and pytest.

## Usage

### Setting up a development environment

```
$ git clone <collection_repo>
$ cd collection_repo
Expand All @@ -35,6 +36,7 @@ INFO Symlinking /home/bthornto/github/ansible.scm/venv/lib64/python3.11/site
```

### Tearing down the development environment

```
$ pipc uninstall ansible.scm
INFO Found collection name: ansible.scm from /home/bthornto/github/ansible.scm/galaxy.yml.
Expand Down Expand Up @@ -82,7 +84,8 @@ Usage:
pipc install -e .[test]
python -m pipc install ansible.utils
```
```

````
$ pipc uninstall --help
usage: pipc uninstall [-h] collection_specifier
Expand All @@ -96,4 +99,5 @@ Usage:
pipc install .
pipc install -e .
pipc install -e .[test]
python -m pipc install ansible.utils```
python -m pipc install ansible.utils```
````
2 changes: 1 addition & 1 deletion src/pipc/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ class Constants:
"""Constants, for now, for pipc."""

TEST_REQUIREMENTS_PY = Path("./test-requirements.txt").resolve()
REQUIMENTS_PY = Path("./requirements.txt").resolve()
REQUIREMENTS_PY = Path("./requirements.txt").resolve()
COLLECTION_BUILD_DIR = Path("./build").resolve()
4 changes: 2 additions & 2 deletions src/pipc/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ def __init__(self: Installer, app: App) -> None:
"""Initialize the installer.
Arguments:
args: The CLI arguments
app: The app instance
"""
self.app: App = app

def run(self: Installer) -> None:
"""Run the installer."""
if self.app.args.collection_specifier.startswith("."):
self._pip_install(C.REQUIMENTS_PY)
self._pip_install(C.REQUIREMENTS_PY)
if "[test]" in self.app.args.collection_specifier:
self._pip_install(C.TEST_REQUIREMENTS_PY)
site_pkg_path = self._install_collection()
Expand Down
5 changes: 4 additions & 1 deletion src/pipc/logger.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Produce coloroed logs."""
"""Produce pretty logs."""

from __future__ import annotations

Expand Down Expand Up @@ -59,6 +59,9 @@ def emit(self: ExitOnExceptionHandler, record: logging.LogRecord) -> None:
Args:
record: The log record
Raises:
SystemExit: If the log record is an error or critical
"""
super().emit(record)
if record.levelno in (logging.ERROR, logging.CRITICAL):
Expand Down
4 changes: 2 additions & 2 deletions src/pipc/uninstaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self: UnInstaller, app: App) -> None:
"""Initialize the uninstaller.
Arguments:
args: The CLI arguments
app: The app instance
"""
self.app: App = app

Expand All @@ -42,7 +42,7 @@ def run(self: UnInstaller) -> None:
logger.critical(err)
return

self._pip_uninstall(C.REQUIMENTS_PY)
self._pip_uninstall(C.REQUIREMENTS_PY)
self._pip_uninstall(C.TEST_REQUIREMENTS_PY)
self._remove_collections()

Expand Down
7 changes: 5 additions & 2 deletions src/pipc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@


def get_galaxy() -> tuple[str, dict[str, str]]:
"""Retreive the collection name from the galaxy.yml file.
"""Retrieve the collection name from the galaxy.yml file.
Returns:
str: The collection name and dependencies
Raises:
SystemExit: If the collection name is not found
"""
file_name = Path("galaxy.yml").resolve()
if not file_name.exists():
Expand All @@ -39,4 +42,4 @@ def get_galaxy() -> tuple[str, dict[str, str]]:
except KeyError as exc:
err = f"Failed to find collection name in {file_name}: {exc}"
logger.critical(err)
raise SystemExit(1) # We shouln't be here
raise SystemExit(1) # We shouldn't be here

0 comments on commit d8ef91d

Please sign in to comment.