Skip to content

Commit

Permalink
Merge pull request #9 from andrewgierens/ci-uplift
Browse files Browse the repository at this point in the history
Ci uplift
  • Loading branch information
andrewgierens authored Dec 5, 2023
2 parents d840ec1 + 27b769f commit 3bff5bd
Show file tree
Hide file tree
Showing 14 changed files with 100 additions and 31 deletions.
5 changes: 5 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[flake8]
max-line-length = 88
extend-ignore = E203
per-file-ignores =
*/__init__.py: F401
31 changes: 31 additions & 0 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Python Lint and Type Check

on:
pull_request:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
container:
image: python:3.11-buster
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.x
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
pip install -r requirements.txt
pip install -r requirements-dev.txt
- name: Set execute permission for build.sh and dist.sh
run: |
chmod +x ./scripts/lint.sh
chmod +x ./scripts/type_check.sh
- name: Run Linting
run: ./scripts/lint.sh
- name: Run Type Checks
run: ./scripts/type_check.sh
File renamed without changes.
18 changes: 18 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.910-1
hooks:
- id: mypy
additional_dependencies: [types-requests]
4 changes: 4 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
flake8
mypy
black
pre-commit
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
aiohttp==3.8.2
pytest-asyncio==0.21.1
pytest-asyncio==0.21.1
pytz==2023.3
types-pytz==2023.3.1.1
3 changes: 3 additions & 0 deletions scripts/format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

black ./tessie_api
3 changes: 3 additions & 0 deletions scripts/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

flake8 ./tessie_api
3 changes: 3 additions & 0 deletions scripts/type_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

mypy ./tessie_api
4 changes: 2 additions & 2 deletions tessie_api/battery_health.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ async def get_battery_health(
session: aiohttp.ClientSession,
vin: str,
api_key: str,
from_time: int = None,
to_time: int = None,
from_time: int,
to_time: int,
distance_format: DistanceFormat = "km",
) -> Dict[str, Any]:
params = {
Expand Down
2 changes: 1 addition & 1 deletion tessie_api/current_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async def get_state_of_all_vehicles(
return await tessieRequest(
session,
"GET",
f"/vehicles",
"/vehicles",
api_key,
params={"only_active": str(only_active).lower()},
)
Expand Down
2 changes: 1 addition & 1 deletion tessie_api/idles.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async def get_idles(
distance_format: DistanceFormat = "km",
format: Format = "json",
timezone: str = "UTC",
exclude_origin: str = False,
exclude_origin: bool = False,
) -> Dict[str, Any]:
return await tessieRequest(
session,
Expand Down
50 changes: 25 additions & 25 deletions tessie_api/literals.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
from typing import Literal
from enum import Enum


MapStyle = Literal["light", "dark"]
DistanceFormat = Literal["mi", "km"]
TemperatureFormat = Literal["c", "f"]
Format = Literal["json", "csv"]
Seat = Literal[
"all",
"front_left",
"front_right",
"rear_left",
"rear_center",
"rear_right",
"third_row_left",
"third_row_right",
]


class ClimateKeeperMode(Enum):
DISABLE = 0
KEEP_MODE = 1
DOG_MODE = 2
CAMP_MODE = 3
from typing import Literal
from enum import Enum


MapStyle = Literal["light", "dark"]
DistanceFormat = Literal["mi", "km"]
TemperatureFormat = Literal["c", "f"]
Format = Literal["json", "csv"]
Seat = Literal[
"all",
"front_left",
"front_right",
"rear_left",
"rear_center",
"rear_right",
"third_row_left",
"third_row_right",
]


class ClimateKeeperMode(Enum):
DISABLE = 0
KEEP_MODE = 1
DOG_MODE = 2
CAMP_MODE = 3
2 changes: 1 addition & 1 deletion tessie_api/tessie_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ async def tessieRequest(
"Content-Type": "application/json",
}
async with session.request(method, url, headers=headers, params=params) as response:
response.raise_for_status() # Will raise aiohttp.ClientResponseError on 4xx or 5xx
response.raise_for_status()
return await response.json()

0 comments on commit 3bff5bd

Please sign in to comment.