Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various fixes and cleanup refactoring #71

Merged
merged 3 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
description: "A breaking change for existing users."
- name: "bugfix"
color: ee0701
description: "Inconsistencies or issues which will cause a problem for users or implementers."
description: "Inconsistencies or issues which will cause a problem for users or implementers." # yamllint disable-line rule:line-length
- name: "documentation"
color: 0052cc
description: "Solely about the documentation of the project."
Expand Down Expand Up @@ -35,7 +35,7 @@
description: "Issue is currently being resolved by a developer."
- name: "stale"
color: fef2c0
description: "There has not been activity on this issue or PR for quite some time."
description: "There has not been activity on this issue or PR for quite some time." # yamllint disable-line rule:line-length
- name: "no-stale"
color: fef2c0
description: "This issue or PR is exempted from the stable bot."
Expand All @@ -52,10 +52,10 @@

- name: "beginner-friendly"
color: 0e8a16
description: "Good first issue for people wanting to contribute to the project."
description: "Good first issue for people wanting to contribute to the project." # yamllint disable-line rule:line-length
- name: "help-wanted"
color: 0e8a16
description: "We need some extra helping hands or expertise in order to resolve this."
description: "We need some extra helping hands or expertise in order to resolve this." # yamllint disable-line rule:line-length

- name: "hacktoberfest"
description: "Issues/PRs are participating in the Hacktoberfest."
Expand All @@ -66,10 +66,10 @@

- name: "priority-critical"
color: ee0701
description: "This should be dealt with ASAP. Not fixing this issue would be a serious error."
description: "This should be dealt with ASAP. Not fixing this issue would be a serious error." # yamllint disable-line rule:line-length
- name: "priority-high"
color: b60205
description: "After critical issues are fixed, these should be dealt with before any further issues."
description: "After critical issues are fixed, these should be dealt with before any further issues." # yamllint disable-line rule:line-length
- name: "priority-medium"
color: 0e8a16
description: "This issue may be useful, and needs some attention."
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/linting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ jobs:
run: poetry run pre-commit run check-case-conflict --all-files
- name: 🚀 Check docstring is first
run: poetry run pre-commit run check-docstring-first --all-files
- name: 🚀 Check that executables have shebangs
run: poetry run pre-commit run check-executables-have-shebangs --all-files # yamllint disable-line rule:line-length
- name: 🚀 Check JSON files
run: poetry run pre-commit run check-json --all-files
- name: 🚀 Check for merge conflicts
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/typing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ jobs:
- name: 🏗 Install dependencies
run: poetry install --no-interaction
- name: 🚀 Run mypy
run: poetry run mypy examples src tests
run: poetry run mypy .
22 changes: 5 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ repos:
name: 🐶 Ruff
language: system
types: [python]
entry: poetry run ruff --fix
entry: poetry run ruff check --fix
require_serial: true
stages: [commit, push, manual]
- id: black
name: ☕️ Format using black
- id: ruff black
name: ☕️ Format using ruff
language: system
types: [python]
entry: poetry run black
entry: poetry run ruff format
require_serial: true
- id: blacken-docs
name: ☕️ Format documentation examples using black
Expand All @@ -35,12 +35,6 @@ repos:
language: system
types: [python]
entry: poetry run check-docstring-first
#- id: check-executables-have-shebangs
# name: 🧐 Check that executables have shebangs
# language: system
# types: [text, executable]
# entry: poetry run check-executables-have-shebangs
# stages: [commit, push, manual]
- id: check-json
name: { Check JSON files
language: system
Expand Down Expand Up @@ -101,7 +95,7 @@ repos:
pass_filenames: false
always_run: true
args:
- --branch=main
- --branch=master
- id: poetry
name: 📜 Check pyproject with Poetry
language: system
Expand All @@ -119,12 +113,6 @@ repos:
language: system
types: [python]
entry: poetry run pylint
- id: pytest
name: 🧪 Running tests and test coverage with pytest
language: system
types: [python]
entry: poetry run pytest
pass_filenames: false
- id: trailing-whitespace
name: ✄ Trim Trailing Whitespace
language: system
Expand Down
30 changes: 17 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,24 @@ import aiohttp
import asyncio
from datetime import datetime


async def main(loop):
async with aiohttp.ClientSession(loop=loop) as session:
train_api = TrafikverketTrain(session, "api_key_here")
stations = await train_api.async_search_train_stations("kristianstad")
for station in stations:
print(station.name + " " + station.signature)

from_station = await train_api.async_get_train_station("Sölvesborg")
to_station = await train_api.async_get_train_station("Kristianstad C")
product_description = "SJ Regional" # Optional search field
print("from_station_signature: " + from_station.signature)
print("to_station_signature: " + to_station.signature)
train_stop = await train_api.async_get_train_stop(from_station, to_station, datetime(2022, 4, 11, 12, 57), product_description);
print(train_stop.get_state())
async with aiohttp.ClientSession(loop=loop) as session:
train_api = TrafikverketTrain(session, "api_key_here")
stations = await train_api.async_search_train_stations("kristianstad")
for station in stations:
print(station.name + " " + station.signature)

from_station = await train_api.async_get_train_station("Sölvesborg")
to_station = await train_api.async_get_train_station("Kristianstad C")
product_description = "SJ Regional" # Optional search field
print("from_station_signature: " + from_station.signature)
print("to_station_signature: " + to_station.signature)
train_stop = await train_api.async_get_train_stop(
from_station, to_station, datetime(2022, 4, 11, 12, 57), product_description
)
print(train_stop.get_state())


loop = asyncio.get_event_loop()
loop.run_until_complete(main(loop))
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "pytrafikverket",
"version": "0.0.0",
"private": true,
"description": "Retreive values from public API at the Swedish Transport Administration (Trafikverket)",
"description": "Retrieve values from public API at the Swedish Transport Administration (Trafikverket)",
"scripts": {
"prettier": "prettier --write **/*.{json,js,md,yml,yaml}"
},
Expand Down
Loading