Skip to content

Commit db496a4

Browse files
committed
0.0.1
1 parent ee95c7f commit db496a4

File tree

14 files changed

+568
-3
lines changed

14 files changed

+568
-3
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
# https://github.com/actions/starter-workflows/blob/main/ci/python-package.yml
3+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
4+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
5+
6+
name: Python package
7+
8+
on:
9+
push:
10+
branches: [main]
11+
pull_request:
12+
branches: [main]
13+
workflow_dispatch:
14+
15+
jobs:
16+
build:
17+
18+
runs-on: ubuntu-latest
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
python-version: ["3.10", "3.11", "3.12", "3.13"]
23+
24+
steps:
25+
- uses: actions/checkout@v3
26+
- name: Set up Python ${{ matrix.python-version }}
27+
uses: actions/setup-python@v4
28+
with:
29+
python-version: ${{ matrix.python-version }}
30+
- name: Install dependencies
31+
run: |
32+
python -m pip install --upgrade pip
33+
python -m pip install .
34+
python -m pip install flake8 pytest python-dotenv ruff mypy
35+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
36+
- name: Lint with flake8
37+
run: |
38+
# stop the build if there are Python syntax errors or undefined names
39+
# exit-zero treats all errors as warnings.
40+
flake8 . --count --exit-zero --show-source --statistics
41+
- name: Lint with ruff
42+
run: |
43+
ruff check .
44+
- name: Static typing with mypy
45+
run: |
46+
mypy --install-types --non-interactive .
47+
- name: Test with pytest
48+
run: |
49+
pytest
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
# https://github.com/actions/starter-workflows/blob/main/ci/python-publish.yml
3+
# This workflow will upload a Python Package to PyPI when a release is created
4+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
5+
6+
# This workflow uses actions that are not certified by GitHub.
7+
# They are provided by a third-party and are governed by
8+
# separate terms of service, privacy policy, and support
9+
# documentation.
10+
11+
name: Upload Python Package
12+
13+
on:
14+
release:
15+
types: [published]
16+
17+
permissions:
18+
contents: read
19+
20+
jobs:
21+
release-build:
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
- uses: actions/setup-python@v5
28+
with:
29+
python-version: "3.x"
30+
31+
- name: Build release distributions
32+
run: |
33+
python -m pip install build
34+
python -m build
35+
36+
- name: Upload distributions
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: release-dists
40+
path: dist/
41+
42+
pypi-publish:
43+
runs-on: ubuntu-latest
44+
needs:
45+
- release-build
46+
permissions:
47+
# IMPORTANT: this permission is mandatory for trusted publishing
48+
id-token: write
49+
50+
# Dedicated environments with protections for publishing are strongly recommended.
51+
# For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules
52+
environment:
53+
name: pypi
54+
# OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status:
55+
# url: https://pypi.org/p/solaredge-web
56+
#
57+
# ALTERNATIVE: if your GitHub Release name is the PyPI project version string
58+
# ALTERNATIVE: exactly, uncomment the following line instead:
59+
url: https://pypi.org/project/solaredge-web/${{ github.event.release.name }}
60+
61+
steps:
62+
- name: Retrieve release distributions
63+
uses: actions/download-artifact@v4
64+
with:
65+
name: release-dists
66+
path: dist/
67+
68+
- name: Publish release distributions to PyPI
69+
uses: pypa/gh-action-pypi-publish@release/v1
70+
with:
71+
packages-dir: dist/

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,9 @@ cython_debug/
174174
.abstra/
175175

176176
# Visual Studio Code
177-
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
177+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
178178
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
179-
# and can be added to the global gitignore or merged into this file. However, if you prefer,
179+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
180180
# you could uncomment the following to ignore the enitre vscode folder
181181
# .vscode/
182182

@@ -191,4 +191,4 @@ cython_debug/
191191
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
192192
# refer to https://docs.cursor.com/context/ignore-files
193193
.cursorignore
194-
.cursorindexingignore
194+
.cursorindexingignore

.markdownlint.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
# Default state for all rules
3+
default: true
4+
5+
MD013: false # Disable line-length checking
6+
MD033:
7+
allowed_elements: [img] # Allow embedded image tags

.pre-commit-config.yaml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
repos:
3+
- repo: https://github.com/pre-commit/pre-commit-hooks
4+
rev: v5.0.0
5+
hooks:
6+
- id: check-added-large-files
7+
- id: check-ast
8+
- id: check-builtin-literals
9+
- id: check-case-conflict
10+
- id: check-docstring-first
11+
- id: check-executables-have-shebangs
12+
- id: check-json
13+
- id: check-merge-conflict
14+
- id: check-shebang-scripts-are-executable
15+
- id: check-symlinks
16+
- id: check-toml
17+
- id: check-vcs-permalinks
18+
- id: check-xml
19+
- id: check-yaml
20+
- id: debug-statements
21+
- id: destroyed-symlinks
22+
- id: detect-private-key
23+
- id: end-of-file-fixer
24+
- id: fix-byte-order-marker
25+
- id: forbid-submodules
26+
- id: mixed-line-ending
27+
- id: trailing-whitespace
28+
- repo: https://github.com/PyCQA/isort
29+
rev: 5.13.2
30+
hooks:
31+
- id: isort
32+
- repo: https://github.com/psf/black
33+
rev: 24.10.0
34+
hooks:
35+
- id: black
36+
- repo: https://github.com/PyCQA/flake8
37+
rev: 7.1.1
38+
hooks:
39+
- id: flake8
40+
- repo: https://github.com/astral-sh/ruff-pre-commit
41+
rev: v0.9.1
42+
hooks:
43+
- id: ruff
44+
args: [--fix]
45+
- repo: https://github.com/pre-commit/mirrors-mypy
46+
rev: v1.14.1
47+
hooks:
48+
- id: mypy
49+
args: [--strict]
50+
additional_dependencies:
51+
[
52+
aiohttp,
53+
]
54+
- repo: https://github.com/asottile/pyupgrade
55+
rev: v3.19.1
56+
hooks:
57+
- id: pyupgrade
58+
args: [--py310-plus]
59+
- repo: https://github.com/adrienverge/yamllint.git
60+
rev: v1.35.1
61+
hooks:
62+
- id: yamllint
63+
- repo: https://github.com/igorshubovych/markdownlint-cli
64+
rev: v0.43.0
65+
hooks:
66+
- id: markdownlint
67+
- repo: https://github.com/codespell-project/codespell
68+
rev: v2.3.0
69+
hooks:
70+
- id: codespell
71+
72+
ci:
73+
autoupdate_schedule: monthly

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# solaredge-web
2+
3+
A python client library for SolarEdge Web.
4+
Fetches energy data for each inverter/string/module via the web API and not via the official API which doesn't expose this data.
5+
6+
## Development environment
7+
8+
```sh
9+
python3 -m venv .venv
10+
source .venv/bin/activate
11+
# for Windows CMD:
12+
# .venv\Scripts\activate.bat
13+
# for Windows PowerShell:
14+
# .venv\Scripts\Activate.ps1
15+
16+
# Install dependencies
17+
python -m pip install --upgrade pip
18+
python -m pip install -e .
19+
20+
# Run pre-commit
21+
python -m pip install pre-commit
22+
pre-commit install
23+
pre-commit run --all-files
24+
25+
# Alternative: run formatter, lint, and type checking
26+
python -m pip install isort black flake8 ruff mypy
27+
isort . ; black . ; flake8 . ; ruff check . --fix ; mypy --install-types .
28+
29+
# Run tests
30+
python -m pip install pytest
31+
pytest
32+
33+
# Build package
34+
python -m pip install build
35+
python -m build
36+
```

mypy.ini

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[mypy]
2+
exclude = (venv|build)
3+
python_version = 3.10
4+
show_error_codes = true
5+
follow_imports = normal
6+
local_partial_types = true
7+
strict_equality = true
8+
no_implicit_optional = true
9+
warn_incomplete_stub = true
10+
warn_redundant_casts = true
11+
warn_unused_configs = true
12+
warn_unused_ignores = true
13+
enable_error_code = ignore-without-code, redundant-self, truthy-iterable
14+
disable_error_code = annotation-unchecked, import-not-found, import-untyped
15+
extra_checks = false
16+
check_untyped_defs = true
17+
disallow_incomplete_defs = true
18+
disallow_subclassing_any = true
19+
disallow_untyped_calls = true
20+
disallow_untyped_decorators = true
21+
disallow_untyped_defs = true
22+
warn_return_any = true
23+
warn_unreachable = true

pyproject.toml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
[project]
2+
name = "solaredge-web"
3+
version = "0.0.1"
4+
license = {text = "Apache-2.0"}
5+
authors = [
6+
{ name="tronikos", email="tronikos@gmail.com" },
7+
]
8+
description = "A python client library for SolarEdge Web"
9+
readme = "README.md"
10+
requires-python = ">=3.10"
11+
dependencies = [
12+
"aiohttp>=3.8",
13+
]
14+
15+
[project.urls]
16+
"Homepage" = "https://github.com/tronikos/solaredge-web"
17+
"Bug Tracker" = "https://github.com/tronikos/solaredge-web/issues"
18+
19+
[build-system]
20+
requires = ["setuptools"]
21+
build-backend = "setuptools.build_meta"
22+
23+
[tool.black]
24+
extend-exclude = "_pb2.py|_pb2_grpc.py"
25+
26+
[tool.isort]
27+
profile = "black"
28+
force_sort_within_sections = true
29+
combine_as_imports = true
30+
extend_skip_glob = ["*_pb2.py", "*_pb2_grpc.py"]
31+
32+
[tool.ruff]
33+
target-version = "py311"
34+
exclude = ["*_pb2.py", "*_pb2_grpc.py", "*.pyi"]
35+
line-length = 127
36+
37+
lint.select = [
38+
"B007", # Loop control variable {name} not used within loop body
39+
"B014", # Exception handler with duplicate exception
40+
"C", # complexity
41+
"D", # docstrings
42+
"E", # pycodestyle
43+
"F", # pyflakes/autoflake
44+
"ICN001", # import concentions; {name} should be imported as {asname}
45+
"PGH004", # Use specific rule codes when using noqa
46+
"PLC0414", # Useless import alias. Import alias does not rename original package.
47+
"SIM105", # Use contextlib.suppress({exception}) instead of try-except-pass
48+
"SIM117", # Merge with-statements that use the same scope
49+
"SIM118", # Use {key} in {dict} instead of {key} in {dict}.keys()
50+
"SIM201", # Use {left} != {right} instead of not {left} == {right}
51+
"SIM212", # Use {a} if {a} else {b} instead of {b} if not {a} else {a}
52+
"SIM300", # Yoda conditions. Use 'age == 42' instead of '42 == age'.
53+
"SIM401", # Use get from dict with default instead of an if block
54+
"T20", # flake8-print
55+
"TRY004", # Prefer TypeError exception for invalid type
56+
"RUF006", # Store a reference to the return value of asyncio.create_task
57+
"UP", # pyupgrade
58+
"W", # pycodestyle
59+
]
60+
61+
lint.ignore = [
62+
"D203", # 1 blank line required before class docstring
63+
"D213", # Multi-line docstring summary should start at the second line
64+
# keep-runtime-annotations
65+
'UP006', # Non PEP585 annotations
66+
'UP007', # Non PEP604 annotations
67+
]
68+
69+
[tool.ruff.lint.flake8-pytest-style]
70+
fixture-parentheses = false
71+
72+
[tool.ruff.lint.per-file-ignores]
73+
# Allow for main script to write to stdout
74+
"__main__.py" = ["T201"]
75+
76+
[tool.ruff.lint.mccabe]
77+
max-complexity = 25
78+
79+
[project.optional-dependencies]
80+
dev = [
81+
"pytest>=7",
82+
]

setup.cfg

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[flake8]
2+
exclude = .venv,.git,docs,venv,bin,lib,deps,build,*_pb2.py,*_pb2_grpc.py
3+
max-complexity = 25
4+
doctests = True
5+
# To work with Black
6+
# E501: line too long
7+
# W503: Line break occurred before a binary operator
8+
# E203: Whitespace before ':'
9+
# D202 No blank lines allowed after function docstring
10+
# W504 line break after binary operator
11+
ignore =
12+
E501,
13+
W503,
14+
E203,
15+
D202,
16+
W504
17+
noqa-require-code = True

src/solaredge_web/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"""A python client library for SolarEdge Web."""
2+
3+
from .solaredge import EnergyData, SolarEdgeWeb, TimeUnit
4+
5+
__all__ = [
6+
"SolarEdgeWeb",
7+
"TimeUnit",
8+
"EnergyData",
9+
]

0 commit comments

Comments
 (0)