frequenz-microgrid 0.2.2

A high-level interface to the Frequenz Microgrid API.
Documentation
# License: MIT
# Copyright © 2022 Frequenz Energy-as-a-Service GmbH

[build-system]
requires = [
  "setuptools == 80.9.0",
  "setuptools_scm[toml] == 8.3.1",
  "frequenz-repo-config[api] == 0.13.5",
  # We need to pin the protobuf, grpcio and  grpcio-tools dependencies to make
  # sure the code is generated using the minimum supported versions, as older
  # versions can't work with code that was generated with newer versions.
  # https://protobuf.dev/support/cross-version-runtime-guarantee/#backwards
  "protobuf == 6.31.1",
  "grpcio-tools == 1.72.1",
  "grpcio == 1.72.1",
]
build-backend = "setuptools.build_meta"

[project]
name = "frequenz-api-microgrid"
description = "Frequenz gRPC API for monitoring and control of microgrids"
readme = "README.md"
license = { text = "MIT" }
keywords = ["frequenz", "python", "api", "grpc", "protobuf", "rpc", "microgrid"]
classifiers = [
  "Development Status :: 3 - Alpha",
  "Intended Audience :: Developers",
  "License :: OSI Approved :: MIT License",
  "Programming Language :: Python :: 3",
  "Programming Language :: Python :: 3 :: Only",
  "Topic :: Software Development :: Libraries",
  "Typing :: Typed",
]
requires-python = ">= 3.11, < 4"
dependencies = [
  "frequenz-api-common >= 0.8.0, < 0.9",
  "googleapis-common-protos >= 1.70.0, < 2",
  # We can't widen beyond 6 because of protobuf cross-version runtime guarantees
  # https://protobuf.dev/support/cross-version-runtime-guarantee/#major
  "protobuf >= 6.31.1, < 8", # Do not widen beyond 8!
  # We couldn't find any document with a spec about the cross-version runtime
  # guarantee for grpcio, so unless we find one in the future, we'll assume
  # major version jumps are not compatible
  "grpcio >= 1.72.1, < 2", # Do not widen beyond 2!
]
dynamic = ["version"]

[[project.authors]]
name = "Frequenz Energy-as-a-Service GmbH"
email = "floss@frequenz.com"

[project.optional-dependencies]
dev-flake8 = [
  "flake8 == 7.3.0",
  "flake8-docstrings == 1.7.0",
  "flake8-pyproject == 1.2.3", # For reading the flake8 config from pyproject.toml
  "pydoclint == 0.6.6",
  "pydocstyle == 6.3.0",
]
dev-formatting = ["black == 25.1.0", "isort == 6.0.1"]
dev-mkdocs = [
  "Markdown == 3.8.2",
  "black == 25.1.0",
  "mike == 2.1.3",
  "mkdocs-gen-files == 0.5.0",
  "mkdocs-literate-nav == 0.6.2",
  "mkdocs-macros-plugin == 1.3.7",
  "mkdocs-material == 9.6.15",
  "mkdocstrings[python] == 0.29.1",
  "mkdocstrings-python == 1.16.12",
  "frequenz-repo-config[api] == 0.13.5",
]
dev-mypy = [
  "mypy == 1.16.1",
  "grpc-stubs == 1.53.0.6",
  # For checking the noxfile, docs/ script, and tests
  "frequenz-api-microgrid[dev-mkdocs,dev-noxfile,dev-pytest]",
]
dev-noxfile = ["nox == 2025.5.1", "frequenz-repo-config[api] == 0.13.5"]
dev-pylint = [
  "pylint == 3.3.7",
  # For checking the noxfile, docs/ script, and tests
  "frequenz-api-microgrid[dev-mkdocs,dev-noxfile,dev-pytest]",
]
dev-pytest = [
  "pytest == 8.4.1",
  "frequenz-repo-config[extra-lint-examples] == 0.13.5",
]
dev = [
  "frequenz-api-microgrid[dev-mkdocs,dev-flake8,dev-formatting,dev-mkdocs,dev-mypy,dev-noxfile,dev-pylint,dev-pytest]",
]

[project.urls]
Changelog = "https://github.com/frequenz-floss/frequenz-api-microgrid/releases"
Issues = "https://github.com/frequenz-floss/frequenz-api-microgrid/issues"
Repository = "https://github.com/frequenz-floss/frequenz-api-microgrid"
Support = "https://github.com/frequenz-floss/frequenz-api-microgrid/discussions/categories/support"

[tool.black]
line-length = 88
target-version = ['py311']
include = '\.pyi?$'

[tool.isort]
profile = "black"
line_length = 88
src_paths = ["benchmarks", "examples", "src", "tests"]

[tool.flake8]
# We give some flexibility to go over 88, there are cases like long URLs or
# code in documenation that have extra indentation. Black will still take care
# of making everything that can be 88 wide, 88 wide.
max-line-length = 100
extend-ignore = [
  "E203", # Whitespace before ':' (conflicts with black)
  "W503", # Line break before binary operator (conflicts with black)
]
# pydoclint options
style = "google"
check-return-types = false
check-yield-types = false
arg-type-hints-in-docstring = false
arg-type-hints-in-signature = true
allow-init-docstring = true
check-class-attributes = false

[tool.pylint.similarities]
ignore-comments = ['yes']
ignore-docstrings = ['yes']
ignore-imports = ['no']
min-similarity-lines = 40

[tool.pylint.messages_control]
disable = [
  "too-few-public-methods",
  "too-many-return-statements",
  # disabled because it conflicts with isort
  "wrong-import-order",
  "ungrouped-imports",
  # Checked by mypy (and pylint is very flaky checking these)
  "unsubscriptable-object",
  "no-member",
  "no-name-in-module",
  "possibly-used-before-assignment",
  # Checked by flake8
  "f-string-without-interpolation",
  "line-too-long",
  "missing-function-docstring",
  "redefined-outer-name",
  "unnecessary-lambda-assignment",
  "unused-import",
  "unused-variable",
]

[tool.pytest.ini_options]
addopts = "-vv"
filterwarnings = [
  "error",
  "once::DeprecationWarning",
  "once::PendingDeprecationWarning",
  # We use a raw string (single quote) to avoid the need to escape special
  # chars as this is a regex
  'ignore:Protobuf gencode version .*exactly one major version older.*:UserWarning',
]
testpaths = ["pytests"]

[tool.mypy]
explicit_package_bases = true
namespace_packages = true
# This option disables mypy cache, and it is sometimes useful to enable it if
# you are getting weird intermittent error, or error in the CI but not locally
# (or vice versa). In particular errors saying that type: ignore is not
# used but getting the original ignored error when removing the type: ignore.
# See for example: https://github.com/python/mypy/issues/2960
#no_incremental = true
packages = ["frequenz.api.microgrid"]
strict = true

[[tool.mypy.overrides]]
module = ["mkdocs_macros.*", "sybil", "sybil.*"]
ignore_missing_imports = true

[tool.setuptools.package-dir]
"" = "py"

[tool.setuptools.package-data]
"*" = ["*.pyi"]

[tool.setuptools_scm]
version_scheme = "post-release"

[tool.frequenz-repo-config.protobuf]
include_paths = [
  "submodules/api-common-protos",
  "submodules/frequenz-api-common/proto",
]