Skip to content
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
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
name: Python tests
name: CI
run-name: "${{ github.event_name == 'workflow_dispatch' && format('CI: {0}', github.ref_name) || '' }}"

on:
push:
branches:
- '*'
pull_request:
types: [ opened, synchronize, reopened ]
branches:
- '*'
release:
types: [ published ]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ (github.event_name == 'release' && github.run_id) || github.event.pull_request.number || github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
python-version: [ "3.11", "3.12" ]
python-version: [ "3.11", "3.12", "3.13" ]

steps:
- name: Checkout code
Expand Down Expand Up @@ -44,17 +54,27 @@ jobs:
run: |
poetry install --no-interaction --no-root

- name: Install library
- name: Install as a library
run: poetry install --no-interaction

- name: Run tests with coverage
- name: Run mypy
run: |
poetry run pytest tests --cov --junit-xml=junit/test-results-${{ matrix.python-version }}.xml
poetry run mypy src

- name: Lint with Ruff
run: |
poetry run ruff check .
continue-on-error: true
poetry run ruff check . --output-format=github
if: success() || failure()

- name: Lint with pylint
run: |
poetry run pylint src/**/*.py
if: success() || failure()

- name: Run tests with coverage
run: |
poetry run pytest tests --cov --junit-xml=junit/test-results-${{ matrix.python-version }}.xml
if: success() || failure()

- name: Surface failing tests
uses: pmeier/pytest-results-action@main
Expand All @@ -70,4 +90,32 @@ jobs:

# (Optional) Fail the workflow if no JUnit XML was found.
fail-on-empty: true
if: ${{ always() }}
if: success() || failure()

release:
name: Release to PyPi
if: ${{ github.event_name == 'release' }}
runs-on: ubuntu-latest
needs:
- build

environment:
name: release
url: https://pypi.org/p/saic_ismart_client_ng

permissions:
contents: read

steps:
- name: Check out code from GitHub
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Build and publish to pypi
uses: JRubics/[email protected]
with:
pypi_token: ${{ secrets.PYPI_API_TOKEN }}
27 changes: 0 additions & 27 deletions .github/workflows/python-publish.yml

This file was deleted.

13 changes: 8 additions & 5 deletions examples/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import asyncio
import logging
import sys
Expand All @@ -6,11 +8,12 @@
from saic_ismart_client_ng.model import SaicApiConfiguration


async def main():
config = SaicApiConfiguration(username="[email protected]", password="XXXXX", )
saic_api = SaicApi(
config
async def main() -> None:
config = SaicApiConfiguration(
username="[email protected]",
password="XXXXX",
)
saic_api = SaicApi(config)
await saic_api.login()
while True:
logging.info("Auth token expires at %s", saic_api.token_expiration)
Expand All @@ -26,7 +29,7 @@ async def main():
await asyncio.sleep(10)


if __name__ == '__main__':
if __name__ == "__main__":
logging.basicConfig(
stream=sys.stdout,
format="%(levelname)s [%(asctime)s] %(name)s - %(message)s",
Expand Down
510 changes: 350 additions & 160 deletions poetry.lock

Large diffs are not rendered by default.

183 changes: 166 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
[tool.poetry]
[project]
name = "saic_ismart_client_ng"
homepage = "https://github.com/SAIC-iSmart-API/saic-python-client-ng"
version = "0.7.1"
version = "0.8.0"
description = "SAIC next gen client library (MG iSMART)"
authors = [
"Giovanni Condello <[email protected]>",
{ name = "Giovanni Condello", email = "[email protected]" },
]
readme = "README.md"

Expand All @@ -14,26 +13,29 @@ classifiers = [
"Operating System :: OS Independent",
]

[tool.poetry.urls]
"Bug Tracker" = "https://github.com/SAIC-iSmart-API/saic-python-client-ng/issues"
requires-python = ">=3.11"

dependencies = [
"pycryptodome (>=3.20.0,<4.0.0)",
"httpx (>=0.27.0,<0.29.0)",
"tenacity (>=9.0.0,<10.0.0)",
"dacite (>=1.8.1,<2.0.0)"
]

[tool.poetry.dependencies]
python = "^3.11"
pycryptodome = "^3.20.0"
httpx = ">=0.27.0,<0.29.0"
tenacity = "^9.0.0"
dacite = "^1.8.1"

[project.urls]
Homepage = "https://github.com/SAIC-iSmart-API/saic-python-client-ng"
Issues = "https://github.com/SAIC-iSmart-API/saic-python-client-ng/issues"

[tool.poetry.dev-dependencies]
[tool.poetry.group.dev.dependencies]
pytest = "^8.2.2"
mock = "^5.1.0"
coverage = "^7.5.4"
ruff = "^0.6.0"
ruff = "^0.11.7"
pytest-cov = "^5.0.0"
pytest-asyncio = "^0.24.0"
pytest-mock = "^3.14.0"
mypy = "^1.15.0"
pylint = "^3.3.6"



Expand All @@ -51,7 +53,7 @@ mock_use_standalone_module = true
addopts = [
"--import-mode=importlib",
]
asyncio_default_fixture_loop_scope="function"
asyncio_default_fixture_loop_scope = "function"

[tool.coverage.run]
omit = [
Expand All @@ -78,4 +80,151 @@ exclude_lines = [
ignore_errors = true

[tool.ruff]
output-format = "github"
include = [
"src/**/*.py",
"tests/**/*.py",
"**/pyproject.toml"
]
[tool.ruff.lint]
select = ["ALL"]

ignore = [
"ANN401", # Opinioated warning on disallowing dynamically typed expressions
"D203", # Conflicts with other rules
"D213", # Conflicts with other rules
"EM101", # raw-string-in-exception

"D105", # Missing docstring in magic method
"D107", # Missing docstring in `__init__`
"E501", # line too long

"FBT", # flake8-boolean-trap

"PLR2004", # Magic value used in comparison, consider replacing {value} with a constant variable

# Used to map JSON responses
"N815",
# Conflicts with the Ruff formatter
"COM812",
# We use Exception istead of Error
"N818",
# Remove later
"D100", # Missing docstring in public module
"D101", # Missing docstring in public class
"D102", # Missing docstring in public method
"D103", # Missing docstring in public function
"D104", # Missing docstring in public package
"D106", # Missing docstring in public nested class
"TD", # Todos
"A", # bultins
"DTZ", # use tz need to test it first
"TRY", # tryceratops
"FIX002", # Line contains TODO, consider resolving the issue
"BLE001", # Do not catch blind exception: `Exception`,
"PLR0913", # Too many arguments in function definition
"ERA001" # Commented-out code

]

[tool.ruff.lint.flake8-pytest-style]
fixture-parentheses = false


[tool.ruff.lint.isort]
combine-as-imports = true
force-sort-within-sections = true
known-first-party = ["saic_ismart_client_ng"]
required-imports = ["from __future__ import annotations"]


[tool.ruff.lint.per-file-ignores]
"tests/**" = [
"D100", # Missing docstring in public module
"D103", # Missing docstring in public function
"D104", # Missing docstring in public package
"N802", # Function name {name} should be lowercase
"N816", # Variable {name} in global scope should not be mixedCase
"PLR0913", # Too many arguments in function definition
"S101", # Use of assert detected
"SLF001", # Private member accessed: {access}
"T201", # print found
]

[tool.ruff.lint.mccabe]
max-complexity = 13

[tool.ruff.lint.pylint]
max-args = 7

[tool.mypy]
files = ["./src", "./tests"]
python_version = 3.11
show_error_codes = true
strict_equality = true
warn_incomplete_stub = true
warn_redundant_casts = true
warn_unused_configs = true
warn_unused_ignores = true
check_untyped_defs = true
disallow_incomplete_defs = true
disallow_subclassing_any = true
disallow_untyped_calls = true
disallow_untyped_decorators = true
disallow_untyped_defs = true
no_implicit_optional = true
warn_return_any = true
warn_unreachable = true
strict = true

[tool.pylint.MAIN]
py-version = "3.11"
ignore = ["tests"]
fail-on = ["I"]

[tool.pylint.BASIC]
good-names = ["i", "j", "k", "ex", "_", "T", "x", "y", "id", "tg"]

[tool.pylint."MESSAGES CONTROL"]
# Reasons disabled:
# format - handled by black
# duplicate-code - unavoidable
# cyclic-import - doesn't test if both import on load
# abstract-class-little-used - prevents from setting right foundation
# too-many-* - are not enforced for the sake of readability
# too-few-* - same as too-many-*
# abstract-method - with intro of async there are always methods missing
# inconsistent-return-statements - doesn't handle raise
# too-many-ancestors - it's too strict.
# wrong-import-order - isort guards this
# ---
# Pylint CodeStyle plugin
# consider-using-namedtuple-or-dataclass - too opinionated
# consider-using-assignment-expr - decision to use := better left to devs
disable = [
"format",
"cyclic-import",
"duplicate-code",
"too-many-arguments",
"too-many-instance-attributes",
"too-many-locals",
"too-many-ancestors",
"too-few-public-methods",
"invalid-name",
# Remove later
"missing-function-docstring",
"missing-module-docstring",
"missing-class-docstring",
"broad-exception-caught",
"logging-fstring-interpolation",
"fixme"
]
enable = ["useless-suppression", "use-symbolic-message-instead"]

[tool.pylint.REPORTS]
score = false

[tool.pylint.FORMAT]
expected-line-ending-format = "LF"

[tool.pylint.EXCEPTIONS]
overgeneral-exceptions = ["builtins.BaseException", "builtins.Exception"]
Loading
Loading