Skip to content

Commit

Permalink
feat(stuff): Added a lot of things
Browse files Browse the repository at this point in the history
- Added README
- Added ISSUE_TEMPLATES
- Added CIs for linting, publishing, and building test
- Refactored code to separate logic and cli code
- Added pre-commit config and hooks
  • Loading branch information
ma7dev committed Aug 27, 2022
1 parent 2fc83f3 commit 3cc9969
Show file tree
Hide file tree
Showing 15 changed files with 406 additions and 124 deletions.
34 changes: 34 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''

---

**Describe the bug**
<!-- A clear and concise description of what the bug is. -->

**To Reproduce**
<!--
Steps to reproduce the behavior
You can paste your code snippet here. Please enclose them
```
like so
```
-->

**Expected behavior**
<!-- A clear and concise description of what you expected to happen. -->

**Screenshots**
<!-- If applicable, add screenshots to help explain your problem. -->

**Additional context**
<!-- Add any other context about the problem here. -->

**System Information**
- Operating System:
- Python Version:
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ''

---

**Describe the solution you'd like**
<!-- A clear and concise description of what you want to happen. -->

**Additional context**
<!-- Add any other context or screenshots about the feature request here. -->
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CI Workflow

on:
push:
branches: ["main", "develop"]
pull_request:
branches: ["main", "develop"]

jobs:
build:
name: CI Workflow
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8.13"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Setup dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry
poetry install
# - name: Run tests
# run: |
# poetry run pytest
- name: Build wheels
run: |
poetry build
35 changes: 35 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Linting

on:
push:
branches: ["main", "develop"]
pull_request:
branches: ["main", "develop"]

jobs:
lint:
name: Lint everything
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8.13"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry
poetry install
- name: Check with black
run: poetry run black --check pyreqpp/
- name: Check with pycln
run: poetry run pycln --check pyreqpp/
- name: Check with isort
run: poetry run isort --check pyreqpp/
- name: Mypy analysis
run: poetry run mypy pyreqpp/
34 changes: 34 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Publish to PyPI

on:
push:
branches: ['main']

jobs:
publish:
name: Publish to PyPI
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8.13"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Setup dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry
poetry install
# - name: Run tests
# run: |
# poetry run pytest
- name: Build wheels
run: |
poetry build
- name: Publish Package
run: |
python -m poetry publish --username=${{ secrets.PYPIUSERNAME }} --password=${{ secrets.PYPIPASSWORD }}
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# development
.hypothesis
.vscode
.pytest
.pytest_cache
__pycache__
poetry.lock
.mypy_cache

poetry.lock
.secrets
48 changes: 48 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: check-ast
- id: check-builtin-literals
- id: check-case-conflict
- id: check-docstring-first
- id: check-merge-conflict
- id: check-json
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
- id: check-vcs-permalinks
- id: check-shebang-scripts-are-executable
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
hooks:
- id: python-check-mock-methods
- id: python-no-log-warn
- id: python-use-type-annotations
- repo: https://github.com/hadialqattan/pycln
rev: v1.2.5
hooks:
- id: pycln
args: [--all]
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
additional_dependencies: ['click==8.0.4']
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
args: ["--profile", "black"]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.800
hooks:
- id: mypy
name: mypy
files: ^pyreqpp/
exclude: (/tests/)|(/docs/)|(/examples/)
args: ["--ignore-missing-imports"]
7 changes: 7 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- id: pyrqpp
name: pyrqpp
description: "A requirements.txt checker and modifier"
entry: pyrqpp
language: python
language_version: python3
types: [python]
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<div align="center">
<p align="center">
<h1>PyReqPP</h1>
</p>

---

<!-- prettier-ignore -->

[![PyPI python](https://img.shields.io/pypi/pyversions/pyreqpp)](https://pypi.org/project/pyreqpp)
[![PyPI version](https://badge.fury.io/py/pyreqpp.svg)](https://pypi.org/project/pyreqpp)
[![Downloads](https://static.pepy.tech/badge/pyreqpp)](https://pepy.tech/project/pyreqpp)
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENCE)

</div>

## Installation

```bash
pip install pyreqpp
```
55 changes: 52 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,66 @@
[tool.poetry]
name = "pyreqpp"
version = "0.1.0"
version = "0.1.1"
description = "Takes requirements.txt file without module versions and annotates it with the latest set of module versions that won't result in build/runtime errors."
authors = ["sudomaze <sudomaze@gmail.com>"]
license = "MIT"

homepage = "https://github.com/sudomaze/pyreqpp"
repository = "https://github.com/sudomaze/pyreqpp"
# NOTE(sudomaze): set of classifiers is taken from https://pypi.org/classifiers/
classifiers = [
"Development Status :: 2 - Pre-Alpha",
"License :: OSI Approved :: MIT License",
"Environment :: Console",
"Intended Audience :: Developers",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS",
"Operating System :: Microsoft :: Windows",
"Programming Language :: Python :: 3.8",
]
[tool.poetry.dependencies]
python = "^3.8.13"
typer = "^0.6.1"
pytest = "^7.1.2"
tomlkit = "^0.11.4"

[tool.poetry.dev-dependencies]
pytest = "^7.1.1"
black = "^22.3.0"
mypy = "^0.961"
pre-commit = "^2.19.0"
isort = "^5.10.1"
pre-commit-hooks = "^4.3.0"
pycln = "^2.0.1"

[tool.mypy]
files = ["^pyreqpp/"]
pretty = true
strict = true
# show_error_codes = true
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
# ignore_missing_imports = true
exclude = "(/tests/)|(/docs/)|(/examples/)"

[tool.pytest]
# log_cli = true
addopts = [
# show summary of all tests that did not pass
"-ra",
# idk
"-s",
# Make tracebacks shorter
"--tb=native",
# enable all warnings
"-Wd",
]
testpaths = ["tests"]
filterwarnings = ["ignore::DeprecationWarning"]

[tool.isort]
profile = "black"
line_length = 79

[tool.black]
line-length = 79 # override the default of 88

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
10 changes: 7 additions & 3 deletions pyreqpp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
#: For more info: https://github.com/hadialqattan/pycln/issues/54
UTF8 = "utf-8"
if "pytest" not in sys.modules:
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding=UTF8) # pragma: nocover
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding=UTF8) # pragma: nocover
sys.stdout = io.TextIOWrapper(
sys.stdout.buffer, encoding=UTF8
) # pragma: nocover
sys.stderr = io.TextIOWrapper(
sys.stderr.buffer, encoding=UTF8
) # pragma: nocover

ISWIN = os.name == "nt"
PYPROJECT_PATH = Path(__file__).parent.parent.joinpath("pyproject.toml")
Expand All @@ -35,4 +39,4 @@ def version_callback(value: bool):
"""Show the version and exit with 0."""
if value:
typer.echo(f"{__name__}, version {__version__}")
raise typer.Exit(0)
raise typer.Exit(0)
2 changes: 1 addition & 1 deletion pyreqpp/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
from . import __name__
from .cli import app

app(prog_name=__name__)
app(prog_name=__name__)
Loading

0 comments on commit 3cc9969

Please sign in to comment.