Skip to content

Commit

Permalink
Merge pull request #29 from IFOSSA/dev
Browse files Browse the repository at this point in the history
Version 0.1.5 merge
  • Loading branch information
loboda4450 authored Dec 17, 2023
2 parents c963567 + 4781ff3 commit ca0054c
Show file tree
Hide file tree
Showing 24 changed files with 3,844 additions and 1,008 deletions.
5 changes: 5 additions & 0 deletions .darglint
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[darglint]
docstring_style=sphinx
ignore=DAR003,DAR402
strictness=full
exclude=docs
6 changes: 6 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[flake8]
max-line-length = 120
max-complexity = 12
select = B,C,E,F,W,T4,B9
ignore = E501, E731, W503, F401, F403
exclude = docs
17 changes: 17 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Code Quality

on:
pull_request:
branches: [dev]

push:
branches: [dev]

jobs:
pre-commit:
name: Linting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/[email protected]
- uses: pre-commit/[email protected]
89 changes: 89 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Pytest

on: [push]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11"]
steps:
- uses: actions/checkout@v3
- uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}

# Cache the installation of Poetry itself, e.g. the next step. This prevents the workflow
# from installing Poetry every time, which can be slow. Note the use of the Poetry version
# number in the cache key, and the "-0" suffix: this allows you to invalidate the cache
# manually if/when you want to upgrade Poetry, or if something goes wrong. This could be
# mildly cleaner by using an environment variable, but I don't really care.
- name: cache poetry install
uses: actions/cache@v2
with:
path: ~/.local
key: poetry-1.5.1-0

# Install Poetry. You could do this manually, or there are several actions that do this.
# `snok/install-poetry` seems to be minimal yet complete, and really just calls out to
# Poetry's default install script, which feels correct. I pin the Poetry version here
# because Poetry does occasionally change APIs between versions and I don't want my
# actions to break if it does.
#
# The key configuration value here is `virtualenvs-in-project: true`: this creates the
# venv as a `.venv` in your testing directory, which allows the next step to easily
# cache it.
- uses: snok/install-poetry@v1
with:
version: 1.5.1
virtualenvs-create: true
virtualenvs-in-project: true

# Cache your dependencies (i.e. all the stuff in your `pyproject.toml`). Note the cache
# key: if you're using multiple Python versions, or multiple OSes, you'd need to include
# them in the cache key. I'm not, so it can be simple and just depend on the poetry.lock.
- name: cache deps
id: cache-deps
uses: actions/cache@v2
with:
path: .venv
key: pydeps-${{ hashFiles('**/poetry.lock') }}

# Install dependencies. `--no-root` means "install all dependencies but not the project
# itself", which is what you want to avoid caching _your_ code. The `if` statement
# ensures this only runs on a cache miss.
- run: poetry install --no-interaction --no-root
if: steps.cache-deps.outputs.cache-hit != 'true'

# Now install _your_ project. This isn't necessary for many types of projects -- particularly
# things like Django apps don't need this. But it's a good idea since it fully-exercises the
# pyproject.toml and makes that if you add things like console-scripts at some point that
# they'll be installed and working.
- run: poetry install --no-interaction

# And finally run tests. I'm using pytest and all my pytest config is in my `pyproject.toml`
# so this line is super-simple. But it could be as complex as you need.
- run: poetry run pytest --junit-xml=test-results.xml

- name: Surface failing tests
if: always()
uses: pmeier/pytest-results-action@main
with:
# A list of JUnit XML files, directories containing the former, and wildcard
# patterns to process.
# See @actions/glob for supported patterns.
path: test-results.xml

# Add a summary of the results at the top of the report
# Default: true
summary: true

# Select which results should be included in the report.
# Follows the same syntax as
# `pytest -r`
# Default: fEX
display-options: fEX

# Fail the workflow if no JUnit XML was found.
# Default: true
fail-on-empty: false
11 changes: 11 additions & 0 deletions .github/workflows/todos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Create issues from todos

on: ["push"]

jobs:
build:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v3"
- name: "TODO to Issue"
uses: "alstr/todo-to-issue-action@v4"
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/log
/otwarcie paczkomatu.xml
/otwarcie_paczkomatu.json
/poetry.lock
/.mypy_cache/
/dist/
/venv/
/.idea/
/tests/.pytest_cache
/tests/__pycache__/
/tests/api_tests.py
/tests/data.json
/tests/data.py
/tests/data_responses.py
/inpost/static/__pycache__/
/inpost/__pycache__/
/otwarcie paczkomatu.xml.html
12 changes: 12 additions & 0 deletions .mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[mypy]
strict = False
# misc disabled due to damn hardcoded Enum, not solved since 2021: https://github.com/python/mypy/issues/11039
# annotation-unchecked just to have clear logs
# assignment cuz i didnt find a way to disable incompatible types in specific conditions, undo before every commit
disable_error_code = misc, annotation-unchecked, assignment

[mypy-tests.*]
allow_untyped_defs = True
allow_untyped_calls = True


35 changes: 35 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
repos:
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
exclude: ^docs/
language_version: python3
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
exclude: ^docs/
additional_dependencies:
- flake8-bugbear
- flake8-comprehensions
- flake8-pytest
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.3.0
hooks:
- id: mypy
exclude: ^docs/
- repo: https://github.com/terrencepreilly/darglint
rev: v1.8.1
hooks:
- id: darglint
exclude: ^docs/
- repo: https://github.com/commitizen-tools/commitizen
rev: v3.3.0
hooks:
- id: commitizen
stages: [commit-msg]
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
[![CodeFactor](https://www.codefactor.io/repository/github/ifossa/inpost-python/badge)](https://www.codefactor.io/repository/github/ifossa/inpost-python)
![Code Quality](https://github.com/ifossa/inpost-python/actions/workflows/lint.yml/badge.svg?barnch=main)
![Todos](https://github.com/ifossa/inpost-python/actions/workflows/todos.yml/badge.svg?barnch=main)

# Inpost Python

Fully async Inpost library using Python 3.10.




## Documentation

[Readthedocs.io](https://inpost-python.readthedocs.io/en/latest/)
Expand All @@ -17,13 +18,21 @@ Fully async Inpost library using Python 3.10.
```python
from inpost.api import Inpost

inp = await Inpost.from_phone_number('555333444')
inp = Inpost('555333444')
await inp.send_sms_code():
...
if await inp.confirm_sms_code(123321):
print('Congratulations, you initialized successfully!')
```

## Before you contribute

![Contributors](https://contrib.rocks/image?repo=ifossa/inpost-python)

Install linters and checkers, unlinted pull requests will not be approved
```commandline
poetry run pre-commit install
```

## Authors

Expand All @@ -37,3 +46,7 @@ This project is used by the following repos:

[Inpost Telegram Bot](https://github.com/loboda4450/inpost-telegram-bot)



## 😂 Here is a random joke that'll make you laugh!
![Jokes Card](https://readme-jokes.vercel.app/api)
Loading

0 comments on commit ca0054c

Please sign in to comment.