Skip to content
This repository has been archived by the owner on Jul 31, 2022. It is now read-only.

Commit

Permalink
Merge pull request #6 from Preocts/preocts-20220612-pyproject.toml
Browse files Browse the repository at this point in the history
Preocts 20220612 pyproject.toml
  • Loading branch information
Preocts authored Jun 13, 2022
2 parents 3f9e237 + 188c30b commit 25d68df
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 102 deletions.
8 changes: 6 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ repos:
rev: "v4.2.0"
hooks:
- id: check-json
- id: check-toml
- id: check-yaml
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -18,7 +19,7 @@ repos:

# Adds a standard feel to import segments
- repo: https://github.com/asottile/reorder_python_imports
rev: v3.0.1
rev: v3.1.0
hooks:
- id: reorder-python-imports
args: [--py3-plus]
Expand All @@ -42,9 +43,12 @@ repos:
hooks:
- id: flake8
additional_dependencies: [flake8-builtins]
args:
- --ignore=W503,E203
- --max-line-length=88

# Type enforcement for Python
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.942
rev: v0.960
hooks:
- id: mypy
19 changes: 10 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
.PHONY: init
init:
pip install --upgrade pip setuptools wheel pip-tools
pip install --upgrade pip flit

.PHONY: install
install:
[ -f "requirements.txt" ] && pip install -r requirements.txt || true
flit install

.PHONY: install-dev
install-dev:
pip install --editable .
pip install -r requirements-dev.txt
[ -f "requirements.txt" ] && pip install -r requirements.txt || true
[ -f "requirements-dev.txt" ] && pip install -r requirements-dev.txt || true
flit install --symlink
pre-commit install

.PHONY: install
install:
pip install --upgrade .

.PHONY: build-dist
build-dist:
rm -rf ./dist
python setup.py sdist bdist_wheel
flit build

.PHONY: clean-artifacts
clean-artifacts:
Expand Down
29 changes: 23 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,17 @@ call the version of the interpreter used to create the `venv`
Install editable library and development requirements:

```bash
# Update pip and tools
python -m pip install --upgrade pip wheel setuptools
# Update pip and install flit
python -m pip install --upgrade pip flit

# Install development requirements
python -m pip install -r requirements-dev.txt

# Install package
flit install

# Optional: install editable package (pip install -e)
flit install --symlink
```

Install pre-commit [(see below for details)](#pre-commit):
Expand All @@ -142,7 +148,7 @@ pre-commit run --all-files
Run tests:

```bash
tox
tox [-r] [-e py3x]
```

To deactivate (exit) the `venv`:
Expand All @@ -153,6 +159,17 @@ deactivate

---

## Note on flake8:

`flake8` is included in the `requirements-dev.txt` of the project. However it disagrees with `black`, the formatter of choice, on max-line-length and two general linting errors. `.pre-commit-config.yaml` is already configured to ignore these. `flake8` doesn't support `pyproject.toml` so be sure to add the following to the editor of choice as needed.

```ini
--ignore=W503,E203
--max-line-length=88
```

---

## [pre-commit](https://pre-commit.com)

> A framework for managing and maintaining multi-language pre-commit hooks.
Expand All @@ -172,9 +189,9 @@ Makefile.

| PHONY | Description |
| ----------------- | ------------------------------------------------------------------ |
| `init` | Update pip, setuptools, and wheel to newest version |
| `install-dev` | install development requirements and project |
| `install` | install project |
| `init` | Install/Update pip and flit |
| `install` | install project and requirements |
| `install-dev` | install dev requirements, project as editable, and pre-commit |
| `build-dist` | Build source distribution and wheel distribution |
| `clean-artifacts` | Deletes python/mypy artifacts including eggs, cache, and pyc files |
| `clean-tests` | Deletes tox, coverage, and pytest artifacts |
Expand Down
102 changes: 102 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
[build-system]
requires = ["flit_core >=3.2,<4"]
build-backend = "flit_core.buildapi"

[project]
name = "pd_ip_gatherer"
version = "1.0.6"
requires-python = ">=3.8"
description = "Gather PagerDuty webhook IP safelist from their help documents repo"
readme = "README.md"
license = { file = "LICENSE" }
authors = [
{ email = "[email protected]", name = "Preocts" }
]
maintainers = []
keywords = []
classifiers = [
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: Implementation :: CPython"
]
dependencies = []

[project.optional-dependencies]
example = []

[project.urls]
homepage = "https://github.com/Preocts/pagerduty-safelist-gatherer"
# documentation = ""
# repository = ""
# changelog = ""

[project.scripts]
pd-ip-gatherer = "pd_ip_gatherer:_console_output"

[tool.mypy]
check_untyped_defs = true
disallow_any_generics = true
disallow_incomplete_defs = true
disallow_untyped_defs = true
no_implicit_optional = true
warn_redundant_casts = true
warn_unused_ignores = true

[[tool.mypy.overrides]]
module = "tests.*"
disallow_incomplete_defs = false
disallow_untyped_defs = false

[tool.coverage.run]
branch = true
source = [ "tests" ]
source_pkgs = [ "." ]

[tool.coverage.report]
exclude_lines =[
"pragma: no cover",
"def __repr__",
"if self\\.debug",
"raise AssertionError",
"raise NotImplementedError",
"if 0:",
"if __name__ == .__main__.:"
]
ignore_errors = true

[tool.coverage.html]
directory = "coverage_html_report"

[tool.coverage.xml]
output = "coverage.xml"

# This is ignored by flake8, here in case they decide to add it in the future
[tool.flake8]
ignore = "W503,E203"
max-line-length = 88

[tool.tox]
legacy_tox_ini = """
[tox]
envlist = py38,py39,py310,py311,pre-commit
skip_missing_interpreters = true
skipsdist = True
[testenv]
commands =
python -m pip install --upgrade coverage pytest
coverage erase
coverage run -m pytest {posargs:tests}
coverage xml
coverage report -m --fail-under 90 --skip-covered
[testenv:pre-commit]
skip_install = true
deps = pre-commit
commands = pre-commit run --all-files --show-diff-on-failure
"""
65 changes: 0 additions & 65 deletions setup.cfg

This file was deleted.

3 changes: 0 additions & 3 deletions setup.py

This file was deleted.

17 changes: 0 additions & 17 deletions tox.ini

This file was deleted.

0 comments on commit 25d68df

Please sign in to comment.