Skip to content

Commit

Permalink
feat: python 3.11 and poetry refactor (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
hairmare committed Jun 16, 2023
1 parent afac4b4 commit e790fde
Show file tree
Hide file tree
Showing 19 changed files with 506 additions and 85 deletions.
33 changes: 0 additions & 33 deletions .flake8

This file was deleted.

14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: pip
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "daily"
13 changes: 13 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Release

on:
push:
tags:
- 'v*.*.*'
pull_request:

jobs:
python-poetry:
uses: radiorabe/actions/.github/workflows/release-python-poetry.yaml@v0.13.1
secrets:
RABE_PYPI_TOKEN: ${{ secrets.RABE_PYPI_TOKEN }}
13 changes: 13 additions & 0 deletions .github/workflows/semantic-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Semantic Release

on:
push:
branches:
- main
- release/*

jobs:
semantic-release:
uses: radiorabe/actions/.github/workflows/semantic-release.yaml@v0.13.1
secrets:
RABE_ITREAKTION_GITHUB_TOKEN: ${{ secrets.RABE_ITREAKTION_GITHUB_TOKEN }}
10 changes: 10 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Test

on:
pull_request:

jobs:
pre-commit:
uses: radiorabe/actions/.github/workflows/test-pre-commit.yaml@v0.13.1
python-poetry:
uses: radiorabe/actions/.github/workflows/test-python-poetry.yaml@v0.13.1
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.coverage
__pycache__/
venv
7 changes: 0 additions & 7 deletions .isort.cfg

This file was deleted.

39 changes: 30 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,39 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v2.31.1
hooks:
- id: pyupgrade
args:
- --py311-plus
- repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: "v0.0.269"
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: local
hooks:
- id: black
name: black
language: system
entry: black
types: [python]
- id: isort
name: isort
language: system
entry: isort -y
entry: isort
types: [python]
- id: flake8
name: flake8
- id: black
name: black
language: system
entry: flake8
entry: black
types: [python]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
exclude: ^src/api/client.js$
- id: end-of-file-fixer
exclude: ^src/api/client.js$
- id: check-symlinks
- id: check-merge-conflict
- id: check-case-conflict
- id: detect-aws-credentials
args:
- --allow-missing-credentials
- id: detect-private-key
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,26 @@ Please raise an [issue](https://github.com/radiorabe/axia-pathfinder-client/issu

Please let us know what you would like to contribute before you get invested! This is really a proof of concept at this stage.

### Development

```bash
python -mvenv venv
. venv/bin/activate

pip install poetry

poetry install
```

### pre-commit hook

```bash
pip install pre-commit
pip install -r requirements-dev.txt -U
pre-commit install
pre-commit run -a
```

### Testing

```bash
pytest
poetry run pytest
```
4 changes: 2 additions & 2 deletions pathfinder/operators/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ class Get(BaseOperator):
def execute(self):
p = ResponseParser()
self.client.write(
"GET {0}".format(self.config.get("path")).encode("ascii") + b"\r\n"
"GET {}".format(self.config.get("path")).encode("ascii") + b"\r\n"
)
results = []
while True:
data = self.client.read_until(b"\r\n", timeout=1)
if data is b"":
if data == b"":
break
if data != b"\r\n":
results.append(p.parse(data.decode("ascii").rstrip("\r\n")))
Expand Down
4 changes: 2 additions & 2 deletions pathfinder/operators/gpo.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ class GPO(BaseOperator):
def execute(self):
p = ResponseParser()
self.client.write(
"GPO {0}".format(self.config.get("number")).encode("ascii") + b"\r\n"
"GPO {}".format(self.config.get("number")).encode("ascii") + b"\r\n"
)
results = []
while True:
data = self.client.read_until(b"\r\n", timeout=1)
if data is b"":
if data == b"":
break
if data != b"\r\n":
results.append(p.parse(data.decode("ascii").rstrip("\r\n")))
Expand Down
8 changes: 5 additions & 3 deletions pathfinder/operators/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
Login to pathfinder.
>>> from pathfinder.operators.login import Login
>>> l = Login(client=client, config={"host": "pathfinder", "user": "Admin", "pass": "Admin"})
>>> c = {"host": "pathfinder", "user": "Admin", "pass": "Admin"}
>>> l = Login(client=client, config=c)
>>> l.execute()
True
>>> l = Login(client=client, config={"host": "pathfinder", "user": "Admin", "pass": "Nope"})
>>> c = {"host": "pathfinder", "user": "Admin", "pass": "Nope"}
>>> l = Login(client=client, config=c)
>>> l.execute()
False
"""
Expand All @@ -22,7 +24,7 @@ class Login(BaseOperator):

def execute(self):
self.client.write(
"LOGIN {0} {1}".format(
"LOGIN {} {}".format(
self.config.get("user"), self.config.get("pass")
).encode("ascii")
+ b"\r\n"
Expand Down
Loading

0 comments on commit e790fde

Please sign in to comment.