diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 0260fe56..8992c1f4 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -3,7 +3,7 @@ updates: - package-ecosystem: "pip" directory: "/" schedule: - interval: "daily" + interval: "weekly" time: "07:00" labels: - "part:tooling" @@ -13,11 +13,28 @@ updates: versioning-strategy: auto # Allow up to 10 open pull requests for updates to dependency versions open-pull-requests-limit: 10 + # We group production and development ("optional" in the context of + # pyproject.toml) dependency updates when they are patch and minor updates, + # so we end up with less PRs being generated. + # Major updates are still managed, but they'll create one PR per + # dependency, as major updates are expected to be breaking, it is better to + # manage them individually. + groups: + required: + dependency-type: "production" + update-types: + - "minor" + - "patch" + optional: + dependency-type: "development" + update-types: + - "minor" + - "patch" - package-ecosystem: "github-actions" directory: "/" schedule: - interval: "daily" + interval: "weekly" time: "06:00" labels: - "part:tooling" @@ -34,10 +51,8 @@ updates: # + `allow` one doesn't seem to work. ignore: - dependency-name: "submodules/frequenz-api-common" - # The google api common repo changes very seldom, so there is no need to - # check very often. schedule: - interval: "monthly" + interval: "weekly" time: "06:00" labels: - "part:tooling" diff --git a/.github/labeler.yml b/.github/labeler.yml index 5b60ae65..1d542b9b 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -32,6 +32,6 @@ "part:protobuf": - "proto/**" - + "part:python": - "py/**" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 023aa9b1..dbe99e76 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -55,9 +55,17 @@ jobs: - ubuntu-20.04 python: - "3.11" + nox-session: + # To speed things up a bit we use the special ci_checks_max session + # that uses the same venv to run multiple linting sessions + - "ci_checks_max" + - "pytest_min" runs-on: ${{ matrix.os }} steps: + - name: Print environment (debug) + run: env + - name: Fetch sources uses: actions/checkout@v3 with: @@ -73,11 +81,25 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install -e .[dev-noxfile] + pip freeze + + - name: Create nox venv + env: + NOX_SESSION: ${{ matrix.nox-session }} + run: nox --install-only -e "$NOX_SESSION" + + - name: Print pip freeze for nox venv (debug) + env: + NOX_SESSION: ${{ matrix.nox-session }} + run: | + . ".nox/$NOX_SESSION/bin/activate" + pip freeze + deactivate - name: Run nox - # To speed things up a bit we use the special ci_checks_max session - # that uses the same venv to run multiple linting sessions - run: nox -e ci_checks_max pytest_min + env: + NOX_SESSION: ${{ matrix.nox-session }} + run: nox -R -e "$NOX_SESSION" timeout-minutes: 10 build: @@ -99,6 +121,7 @@ jobs: run: | python -m pip install -U pip python -m pip install -U build + pip freeze - name: Build the source and binary distribution run: python -m build @@ -133,6 +156,7 @@ jobs: run: | python -m pip install -U pip python -m pip install .[dev-mkdocs] + pip freeze - name: Generate the documentation env: @@ -215,6 +239,7 @@ jobs: run: | python -m pip install -U pip python -m pip install .[dev-mkdocs] + pip freeze - name: Fetch the gh-pages branch if: steps.mike-metadata.outputs.version diff --git a/MANIFEST.in b/MANIFEST.in index 95366aae..c15e5b3d 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,4 @@ exclude .cookiecutter-replay.json -exclude .darglint exclude .editorconfig exclude .gitignore exclude .gitmodules @@ -9,6 +8,7 @@ exclude mkdocs.yml exclude noxfile.py exclude src/conftest.py recursive-exclude .github * +recursive-exclude benchmarks * recursive-exclude docs * recursive-exclude pytests * recursive-include py *.pyi diff --git a/mkdocs.yml b/mkdocs.yml index 0d98a271..523297cd 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -24,6 +24,7 @@ theme: features: - content.code.annotate - content.code.copy + - navigation.indexes - navigation.instant - navigation.tabs - navigation.top @@ -108,7 +109,6 @@ plugins: - https://grpc.github.io/grpc/python/objects.inv - https://typing-extensions.readthedocs.io/en/stable/objects.inv - search - - section-index # Preview controls watch: diff --git a/py/frequenz/api/common/__init__.py b/py/frequenz/api/common/__init__.py new file mode 100644 index 00000000..e423855c --- /dev/null +++ b/py/frequenz/api/common/__init__.py @@ -0,0 +1,7 @@ +# License: MIT +# Copyright © 2023 Frequenz Energy-as-a-Service GmbH + +"""Frequenz common gRPC API and bindings. + +TODO(cookiecutter): Add a more descriptive module description. +""" diff --git a/pyproject.toml b/pyproject.toml index 3659c00c..b825a407 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,9 +3,9 @@ [build-system] requires = [ - "setuptools == 67.7.2", + "setuptools == 68.1.0", "setuptools_scm[toml] == 7.1.0", - "frequenz-repo-config[api] == 0.5.2", + "frequenz-repo-config[api] == 0.6.2", ] build-backend = "setuptools.build_meta" @@ -36,10 +36,12 @@ name = "Frequenz Energy-as-a-Service GmbH" email = "floss@frequenz.com" [project.optional-dependencies] -dev-docstrings = [ +dev-flake8 = [ + "flake8 == 6.1.0", + "flake8-docstrings == 1.7.0", + "flake8-pyproject == 1.2.3", # For reading the flake8 config from pyproject.toml + "pydoclint == 0.3.1", "pydocstyle == 6.3.0", - "darglint == 1.8.1", - "tomli == 2.0.1", # Needed by pydocstyle to read pyproject.toml ] dev-formatting = ["black == 23.10.1", "isort == 5.12.0"] dev-mkdocs = [ @@ -47,16 +49,19 @@ dev-mkdocs = [ "mkdocs-gen-files == 0.5.0", "mkdocs-literate-nav == 0.6.1", "mkdocs-material == 9.4.6", - "mkdocs-section-index == 0.3.8", "mkdocstrings[python] == 0.23.0", - "frequenz-repo-config[api] == 0.5.2", + "frequenz-repo-config[api] == 0.6.2", ] dev-mypy = [ "mypy == 1.6.1", + "grpc-stubs == 1.53.0.2", # For checking the noxfile, docs/ script, and tests "frequenz-api-common[dev-mkdocs,dev-noxfile,dev-pytest]", ] -dev-noxfile = ["nox == 2023.4.22", "frequenz-repo-config[api] == 0.5.2"] +dev-noxfile = [ + "nox == 2023.4.22", + "frequenz-repo-config[api] == 0.6.2", +] dev-pylint = [ "pylint == 2.17.6", # For checking the noxfile, docs/ script, and tests @@ -64,10 +69,10 @@ dev-pylint = [ ] dev-pytest = [ "pytest == 7.4.3", - "frequenz-repo-config[extra-lint-examples] == 0.5.2", + "frequenz-repo-config[extra-lint-examples] == 0.6.2", ] dev = [ - "frequenz-api-common[dev-mkdocs,dev-docstrings,dev-formatting,dev-mkdocs,dev-mypy,dev-noxfile,dev-pylint,dev-pytest]", + "frequenz-api-common[dev-mkdocs,dev-flake8,dev-formatting,dev-mkdocs,dev-mypy,dev-noxfile,dev-pylint,dev-pytest]", ] [project.urls] @@ -85,8 +90,22 @@ profile = "black" line_length = 88 src_paths = ["benchmarks", "examples", "src", "tests"] -[tool.frequenz-repo-config.protobuf] -include_paths = ["submodules/api-common-protos"] +[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 [tool.pylint.similarities] ignore-comments = ['yes'] @@ -103,11 +122,27 @@ disable = [ # pylint's unsubscriptable check is buggy and is not needed because # it is a type-check, for which we already have mypy. "unsubscriptable-object", + # Checked by flake8 + "line-too-long", + "unused-variable", + "unnecessary-lambda-assignment", ] [tool.pytest.ini_options] 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.common"] +strict = true + [tool.setuptools.package-dir] "" = "py"