Skip to content
Open
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
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ format: install-dev

lint: install-dev
$(POETRY) run black --check --extend-exclude test-data/gardenlinux .
$(POETRY) run isort --check-only .
$(POETRY) run pyright

security: install-dev
@if [ "$(CI)" = "true" ]; then \
Expand Down
702 changes: 362 additions & 340 deletions poetry.lock

Large diffs are not rendered by default.

23 changes: 22 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "Contains tools to work with the features directory of gardenlinux
authors = ["Garden Linux Maintainers <[email protected]>"]
license = "Apache-2.0"
readme = "README.md"
packages = [{include = "gardenlinux", from="src"}]
packages = [{ include = "gardenlinux", from = "src" }]

[tool.poetry.dependencies]
python = "^3.13"
Expand All @@ -27,6 +27,8 @@ moto = "^5.1.10"
python-dotenv = "^1.1.1"
pytest = "^8.4.1"
pytest-cov = "^6.2.1"
isort = "^6.0.1"
pyright = "^1.1.403"

[tool.poetry.group.docs.dependencies]
sphinx-rtd-theme = "^3.0.2"
Expand All @@ -42,6 +44,25 @@ gl-s3 = "gardenlinux.s3.__main__:main"
pythonpath = ["src"]
norecursedirs = "test-data"

[tool.isort]
profile = "black"
line_length = 120
known_first_party = ["gardenlinux"]
skip = ["test-data", ".venv", "**/__pycache", ".pytest-cache", "hack"]

[tool.pyright]
typeCheckingMode = "strict"
venvPath = "."
venv = ".venv"
exclude = [
"test-data",
"docs",
"hack",
".venv",
".pytest-cache",
"**/__pycache",
]

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
27 changes: 27 additions & 0 deletions pyrightconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
// Pyright is configured in 'strict' mode in pyproject.toml
// This file overrides some reports and tones them down to warnings, if they are not critical.
// It also turns some up to become warnings or errors.
"reportShadowedImports": "warning",
"reportImportCycles": "error",
"reportOptionalMemberAccess": "warning",
"reportOptionalSubscript": "warning",
"reportOptionalContextManager": "warning",
"reportOptionalCall": "warning",
"reportUnusedVariable": "warning",
"reportUnusedImport": "warning",
"reportUnusedFunction": "warning",
"reportUnusedCallResult": "warning",
"reportUnusedClass": "warning",
"reportUnnecessaryCast": "warning",
"reportUnnecessaryComparison": "warning",
"reportUnnecessaryIsInstance": "warning",
"reportUnnecessaryContains": "warning",
// Becomes useful after introduction of type annotations
// "reportUnknownMemberType": "warning",
// "reportUnknownParameterType": "warning",
// "reportUnknownArgumentType": "warning",
// "reportUnknownVariableType": "warning",
"reportTypedDictNotRequiredAccess": "error",
"reportDeprecated": "warning",
}
3 changes: 2 additions & 1 deletion src/gardenlinux/apt/package_repo_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
APT repositories
"""

from apt_repo import APTRepository
from typing import Optional

from apt_repo import APTRepository


class GardenLinuxRepo(APTRepository):
"""
Expand Down
1 change: 0 additions & 1 deletion src/gardenlinux/features/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from .cname import CName
from .parser import Parser


_ARGS_TYPE_ALLOWED = [
"cname",
"cname_base",
Expand Down
3 changes: 1 addition & 2 deletions src/gardenlinux/features/cname.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
Canonical name (cname)
"""

from typing import Optional
import re
from typing import Optional

from ..constants import ARCHS

from .parser import Parser


Expand Down
9 changes: 4 additions & 5 deletions src/gardenlinux/features/cname_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@
gl-cname main entrypoint
"""

from functools import reduce
from os.path import basename, dirname
import argparse
import logging
import re

from .cname import CName
from .parser import Parser
from functools import reduce
from os.path import basename, dirname

from .__main__ import (
get_cname_base,
get_minimal_feature_set,
get_version_and_commit_id_from_files,
sort_subset,
)
from .cname import CName
from .parser import Parser


def main():
Expand Down
8 changes: 4 additions & 4 deletions src/gardenlinux/features/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
Features parser based on networkx.Digraph
"""

from glob import glob
from typing import Callable, Optional
import logging
import networkx
import os
import re
import subprocess
from glob import glob
from typing import Callable, Optional

import networkx
import yaml

from ..constants import (
ARCHS,
BARE_FLAVOR_FEATURE_CONTENT,
BARE_FLAVOR_LIBC_FEATURE_CONTENT,
)

from ..logger import LoggerSetup


Expand Down
8 changes: 4 additions & 4 deletions src/gardenlinux/flavors/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
gl-flavors-parse main entrypoint
"""

from argparse import ArgumentParser
from pathlib import Path
from tempfile import TemporaryDirectory
import json
import os
import sys
from argparse import ArgumentParser
from pathlib import Path
from tempfile import TemporaryDirectory

from git import Repo
from git.exc import GitError

from .parser import Parser
from ..constants import GL_REPOSITORY_URL
from ..git import Git
from .parser import Parser


def _get_flavors_file_data(flavors_file):
Expand Down
3 changes: 2 additions & 1 deletion src/gardenlinux/flavors/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
Flavors parser
"""

from jsonschema import validate as jsonschema_validate
import fnmatch

import yaml
from jsonschema import validate as jsonschema_validate

from ..constants import GL_FLAVORS_SCHEMA
from ..logger import LoggerSetup
Expand Down
4 changes: 2 additions & 2 deletions src/gardenlinux/git/git.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-

import sys
from os import PathLike
from pathlib import Path
import sys

from git import Repo
from git import Git as _Git
from git import Repo

from ..logger import LoggerSetup

Expand Down
2 changes: 1 addition & 1 deletion src/gardenlinux/oci/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"""

import os
import click

import click
from pygments.lexer import default

from .container import Container
Expand Down
18 changes: 9 additions & 9 deletions src/gardenlinux/oci/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@
"""

import json
import jsonschema
import logging
from base64 import b64encode
from configparser import ConfigParser, UNNAMED_SECTION
from collections.abc import Sequence
from configparser import UNNAMED_SECTION, ConfigParser
from hashlib import sha256
from oras.container import Container as OrasContainer
from oras.defaults import unknown_config_media_type as UNKNOWN_CONFIG_MEDIA_TYPE
from oras.provider import Registry
from oras.utils import make_targz, extract_targz
from os import fdopen, getenv, PathLike
from os import PathLike, fdopen, getenv
from pathlib import Path
from requests import Response
from tempfile import mkstemp
from typing import Optional
from urllib.parse import urlsplit

import jsonschema
from oras.container import Container as OrasContainer
from oras.defaults import unknown_config_media_type as UNKNOWN_CONFIG_MEDIA_TYPE
from oras.provider import Registry
from oras.utils import extract_targz, make_targz
from requests import Response

from ..constants import GL_MEDIA_TYPE_LOOKUP, OCI_IMAGE_INDEX_MEDIA_TYPE
from ..features.cname import CName
from ..logger import LoggerSetup

from .index import Index
from .layer import Layer
from .manifest import Manifest
Expand Down
5 changes: 3 additions & 2 deletions src/gardenlinux/oci/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

from collections.abc import Mapping
from os import PathLike
from oras.defaults import annotation_title as ANNOTATION_TITLE
from oras.oci import Layer as _Layer
from pathlib import Path
from typing import Optional

from oras.defaults import annotation_title as ANNOTATION_TITLE
from oras.oci import Layer as _Layer

from ..constants import GL_MEDIA_TYPE_LOOKUP, GL_MEDIA_TYPES

_SUPPORTED_MAPPING_KEYS = ("annotations",)
Expand Down
6 changes: 3 additions & 3 deletions src/gardenlinux/oci/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import json
from copy import deepcopy
from hashlib import sha256
from oras.defaults import unknown_config_media_type as UNKNOWN_CONFIG_MEDIA_TYPE
from oras.oci import EmptyManifest, Layer
from os import PathLike
from pathlib import Path

from ..features import CName
from oras.defaults import unknown_config_media_type as UNKNOWN_CONFIG_MEDIA_TYPE
from oras.oci import EmptyManifest, Layer

from ..features import CName
from .platform import NewPlatform
from .schemas import EmptyManifestMetadata

Expand Down
1 change: 0 additions & 1 deletion src/gardenlinux/s3/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

from .s3_artifacts import S3Artifacts


_ARGS_ACTION_ALLOWED = [
"download-artifacts-from-bucket",
"upload-artifacts-to-bucket",
Expand Down
7 changes: 4 additions & 3 deletions src/gardenlinux/s3/s3_artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
"""

import logging
import yaml
from configparser import ConfigParser, UNNAMED_SECTION
from configparser import UNNAMED_SECTION, ConfigParser
from datetime import datetime
from hashlib import file_digest
from os import PathLike, stat
Expand All @@ -16,9 +15,11 @@
from typing import Any, Optional
from urllib.parse import urlencode

from .bucket import Bucket
import yaml

from ..features.cname import CName
from ..logger import LoggerSetup
from .bucket import Bucket


class S3Artifacts(object):
Expand Down
3 changes: 2 additions & 1 deletion tests/apt/test_debsource.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from gardenlinux.apt import DebsrcFile
import io

from gardenlinux.apt import DebsrcFile

test_data = """Package: vim
Source: vim (2:9.1.0496-1)
Version: 2:9.1.0496-1+b1
Expand Down
17 changes: 9 additions & 8 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,28 @@
import subprocess
import sys
import tempfile
import pytest
from datetime import datetime, timedelta

import pytest
from cryptography import x509
from cryptography.x509.oid import NameOID
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.primitives.asymmetric import rsa
from datetime import datetime, timedelta
from cryptography.x509.oid import NameOID
from dotenv import load_dotenv

from gardenlinux.features import Parser

from .constants import (
TEST_DATA_DIR,
GL_ROOT_DIR,
CERT_DIR,
GARDENLINUX_ROOT_DIR_EXAMPLE,
GL_ROOT_DIR,
TEST_ARCHITECTURES,
TEST_COMMIT,
TEST_VERSION,
TEST_PLATFORMS,
TEST_DATA_DIR,
TEST_FEATURE_SET,
TEST_FEATURE_STRINGS_SHORT,
TEST_ARCHITECTURES,
TEST_PLATFORMS,
TEST_VERSION,
)
from .helper import call_command, spawn_background_process

Expand Down
3 changes: 2 additions & 1 deletion tests/features/test_cname_main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import logging
import pytest
import sys
import types

import pytest

import gardenlinux.features.cname_main as cname_main
from gardenlinux.features import CName

Expand Down
1 change: 1 addition & 0 deletions tests/features/test_features_parser.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest

from gardenlinux.features import Parser

from ..constants import GL_ROOT_DIR


Expand Down
1 change: 1 addition & 0 deletions tests/features/test_main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
import types

import pytest

import gardenlinux.features.__main__ as fema
Expand Down
Loading
Loading