Skip to content

Commit

Permalink
Merge branch 'main' into fix/455
Browse files Browse the repository at this point in the history
Signed-off-by: Kanishk Pachauri <[email protected]>
  • Loading branch information
Mr-Sunglasses authored Feb 3, 2025
2 parents 19da087 + 1d37d84 commit 25926eb
Show file tree
Hide file tree
Showing 75 changed files with 981 additions and 3,386 deletions.
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ env:
#### Cache-image names to test with (double-quotes around names are critical)
####
# Google-cloud VM Images
IMAGE_SUFFIX: "c20241015t085508z-f40f39d13"
IMAGE_SUFFIX: "c20250107t132430z-f41f40d13"
FEDORA_CACHE_IMAGE_NAME: "fedora-podman-py-${IMAGE_SUFFIX}"


Expand Down
1 change: 1 addition & 0 deletions .fmf/version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
18 changes: 18 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: pre-commit
on:
pull_request:
push:
branches: [main]
jobs:
pre-commit:
runs-on: ubuntu-latest
env:
SKIP: no-commit-to-branch
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: |
3.9
3.x
- uses: pre-commit/[email protected]
10 changes: 10 additions & 0 deletions .packit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,13 @@ jobs:
packages: [python-podman-fedora]
dist_git_branches:
- fedora-branched # rawhide updates are created automatically

# Test linting on the codebase
# This test might break based on the OS and lint used, so we follow fedora-latest as a reference
- job: tests
trigger: pull_request
tmt_plan: /upstream/sanity
packages: [python-podman-fedora]
targets:
- fedora-latest-stable
skip_build: true
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.8.1
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format
- repo: https://github.com/teemtee/tmt.git
rev: 1.39.0
hooks:
- id: tmt-lint
16 changes: 9 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ Please don't include any private/sensitive information in your issue!

## Tools we use

- Python 3.6
- [pylint](https://www.pylint.org/)
- [black](https://github.com/psf/black)
- Python >= 3.9
- [pre-commit](https://pre-commit.com/)
- [ruff](https://docs.astral.sh/ruff/)
- [tox](https://tox.readthedocs.io/en/latest/)
- You may need to use [virtualenv](https://virtualenv.pypa.io/en/latest/) to
support Python 3.6
Expand Down Expand Up @@ -65,10 +65,12 @@ tox -e coverage

## Coding conventions

- Use [black](https://github.com/psf/black) code formatter. If you have tox
installed, run `tox -e black` to see what changes will be made. You can use
`tox -e black-format` to update the code formatting prior to committing.
- Pass pylint
- Formatting and linting are incorporated using [ruff](https://docs.astral.sh/ruff/).
- If you use [pre-commit](https://pre-commit.com/) the checks will run automatically when you commit some changes
- If you prefer to run the ckecks with pre-commit, use `pre-commit run -a` to run the pre-commit checks for you.
- If you'd like to see what's happening with the checks you can run the [linter](https://docs.astral.sh/ruff/linter/)
and [formatter](https://docs.astral.sh/ruff/formatter/) separately with `ruff check --diff` and `ruff format --diff`
- Checks need to pass pylint
- exceptions are possible, but you will need to make a good argument
- Use spaces not tabs for indentation
- This is open source software. Consider the people who will read your code,
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ DESTDIR ?=
EPOCH_TEST_COMMIT ?= $(shell git merge-base $${DEST_BRANCH:-main} HEAD)
HEAD ?= HEAD

export PODMAN_VERSION ?= "5.2.0"
export PODMAN_VERSION ?= "5.3.0"

.PHONY: podman
podman:
Expand All @@ -19,12 +19,12 @@ podman:

.PHONY: lint
lint: tox
$(PYTHON) -m tox -e black,pylint
$(PYTHON) -m tox -e format,lint

.PHONY: tests
tests: tox
# see tox.ini for environment variable settings
$(PYTHON) -m tox -e coverage,py36,py38,py39,py310,py311
$(PYTHON) -m tox -e coverage,py39,py310,py311,py312,py313

.PHONY: unittest
unittest:
Expand All @@ -39,9 +39,9 @@ integration:
.PHONY: tox
tox:
ifeq (, $(shell which dnf))
brew install python@3.8 python@3.9 python@3.10 python@3.11
brew install python@3.9 python@3.10 python@3.11 python@3.12 [email protected]
else
-dnf install -y python3 python3.6 python3.8 python3.9
-dnf install -y python3 python3.9 python3.10 python3.11 python3.12 python3.13
endif
# ensure tox is available. It will take care of other testing requirements
$(PYTHON) -m pip install --user tox
Expand Down
1 change: 1 addition & 0 deletions OWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ reviewers:
- baude
- rhatdan
- TomSweeneyRedHat
- Edward5hen
3 changes: 1 addition & 2 deletions contrib/cirrus/build_podman.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ set -xeo pipefail

systemctl stop podman.socket || :

dnf erase podman -y
dnf remove podman -y
dnf copr enable rhcontainerbot/podman-next -y
dnf install podman -y

1 change: 0 additions & 1 deletion docs/source/_templates/apidoc/toc.rst_t
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@
{% for docname in docnames %}
{{ docname }}
{%- endfor %}

10 changes: 4 additions & 6 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

# -- Project information -----------------------------------------------------

project = u'Podman Python SDK'
copyright = u'2021, Red Hat Inc'
author = u'Red Hat Inc'
project = 'Podman Python SDK'
copyright = '2021, Red Hat Inc'
author = 'Red Hat Inc'

# The full version, including alpha/beta/rc tags
version = '3.2.1.0'
Expand Down Expand Up @@ -125,9 +125,7 @@ class PatchedPythonDomain(PythonDomain):
def resolve_xref(self, env, fromdocname, builder, typ, target, node, contnode):
if 'refspecific' in node:
del node['refspecific']
return super(PatchedPythonDomain, self).resolve_xref(
env, fromdocname, builder, typ, target, node, contnode
)
return super().resolve_xref(env, fromdocname, builder, typ, target, node, contnode)


def skip(app, what, name, obj, would_skip, options):
Expand Down
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ Indices and tables

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
* :ref:`search`
56 changes: 56 additions & 0 deletions plans/main.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
summary: Run Python Podman Tests

discover:
how: fmf
execute:
how: tmt
prepare:
- name: pkg dependencies
how: install
package:
- make
- podman
- python3-pip
- python3.9
- python3.10
- python3.11
- python3.12
- python3.13

- name: pip dependencies
how: shell
script:
- pip3 install -r test-requirements.txt

- name: ssh configuration
how: shell
script:
- ssh-keygen -t ecdsa -b 521 -f /root/.ssh/id_ecdsa -P ""
- cp /root/.ssh/authorized_keys /root/.ssh/authorized_keys%
- cat /root/.ssh/id_ecdsa.pub >>/root/.ssh/authorized_keys

/upstream:
/sanity:
summary: Run Sanity and Coverage checks on Python Podman
discover+:
# we want to change this to tag:stable once all the coverage tests are fixed
filter: tag:lint

/tests:
summary: Run Python Podman Tests on upstream PRs
discover+:
filter: tag:upstream

adjust+:
enabled: false
when: initiator is not defined or initiator != packit

/downstream:
/tests:
summary: Run Python Podman Tests on bodhi / errata and dist-git PRs
discover+:
filter: tag:downstream

adjust+:
enabled: false
when: initiator == packit
4 changes: 0 additions & 4 deletions podman/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
"""Podman client module."""

import sys

assert sys.version_info >= (3, 6), "Python 3.6 or greater is required."

from podman.client import PodmanClient, from_env
from podman.version import __version__

Expand Down
8 changes: 0 additions & 8 deletions podman/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,12 @@

DEFAULT_CHUNK_SIZE = 2 * 1024 * 1024

try:
from typing import Literal
except (ImportError, ModuleNotFoundError):
try:
from typing_extensions import Literal
except (ImportError, ModuleNotFoundError):
from podman.api.typing_extensions import Literal # pylint: disable=ungrouped-imports

# isort: unique-list
__all__ = [
'APIClient',
'COMPATIBLE_VERSION',
'DEFAULT_CHUNK_SIZE',
'Literal',
'VERSION',
'cached_property',
'create_tar',
Expand Down
3 changes: 2 additions & 1 deletion podman/api/adapter_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Utility functions for working with Adapters."""

from typing import NamedTuple, Mapping
from typing import NamedTuple
from collections.abc import Mapping


def _key_normalizer(key_class: NamedTuple, request_context: Mapping) -> Mapping:
Expand Down
21 changes: 14 additions & 7 deletions podman/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
import json
import warnings
import urllib.parse
from typing import Any, ClassVar, IO, Iterable, List, Mapping, Optional, Tuple, Type, Union
from typing import (
Any,
ClassVar,
IO,
Optional,
Union,
)
from collections.abc import Iterable, Mapping

import requests
from requests.adapters import HTTPAdapter
Expand All @@ -20,12 +27,12 @@
str,
bytes,
Mapping[str, Any],
Iterable[Tuple[str, Optional[str]]],
Iterable[tuple[str, Optional[str]]],
IO,
]
"""Type alias for request data parameter."""

_Timeout = Union[None, float, Tuple[float, float], Tuple[float, None]]
_Timeout = Union[None, float, tuple[float, float], tuple[float, None]]
"""Type alias for request timeout parameter."""


Expand Down Expand Up @@ -58,7 +65,7 @@ def __getattr__(self, item: str):
"""Forward any query for an attribute not defined in this proxy class to wrapped class."""
return getattr(self._response, item)

def raise_for_status(self, not_found: Type[APIError] = NotFound) -> None:
def raise_for_status(self, not_found: type[APIError] = NotFound) -> None:
"""Raises exception when Podman service reports one."""
if self.status_code < 400:
return
Expand All @@ -81,7 +88,7 @@ class APIClient(requests.Session):
# Abstract methods (delete,get,head,post) are specialized and pylint cannot walk hierarchy.
# pylint: disable=too-many-instance-attributes,arguments-differ,arguments-renamed

supported_schemes: ClassVar[List[str]] = (
supported_schemes: ClassVar[list[str]] = (
"unix",
"http+unix",
"ssh",
Expand Down Expand Up @@ -156,7 +163,7 @@ def __init__(
self.mount("http://", HTTPAdapter(**http_adapter_kwargs))
self.mount("https://", HTTPAdapter(**http_adapter_kwargs))
else:
assert False, "APIClient.supported_schemes changed without adding a branch here."
raise PodmanError("APIClient.supported_schemes changed without adding a branch here.")

self.version = version or VERSION
self.path_prefix = f"/v{self.version}/libpod/"
Expand Down Expand Up @@ -235,7 +242,7 @@ def get(
self,
path: Union[str, bytes],
*,
params: Union[None, bytes, Mapping[str, List[str]]] = None,
params: Union[None, bytes, Mapping[str, list[str]]] = None,
headers: Optional[Mapping[str, str]] = None,
timeout: _Timeout = None,
stream: Optional[bool] = False,
Expand Down
Loading

0 comments on commit 25926eb

Please sign in to comment.