Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] Use pyproject toml and enable workflow for publishing on PyPI #480

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

inknos
Copy link
Contributor

@inknos inknos commented Dec 11, 2024

This PR incorporates all the building tools in pyproject.toml while keeping most of the changes in the

It also proposes to auto-build pushes and publish signed artifacts on PyPI testing. The process also automates tagged commits publishing to PyPI.

Publishing on PyPI follows this guide

Catching BaseException can make it hard to interrupt the program
(e.g., with Ctrl-C) and can disguise other problems.

Signed-off-by: Nicola Sella <nsella@redhat.com>
Checks for the use of the characters 'l', 'O', or 'I' as variable names.

Signed-off-by: Nicola Sella <nsella@redhat.com>
F401: unused-import

E402: module-import-not-at-top-of-file

S101: assert

Assertions are removed when Python is run with optimization requested
(i.e., when the -O flag is present), which is a common practice in
 production environments. As such, assertions should not be used for
runtime validation of user input or to enforce interface constraints.

Signed-off-by: Nicola Sella <nsella@redhat.com>

Unused import

Signed-off-by: Nicola Sella <nsella@redhat.com>
Check for unused variables. Unused variables should be prefixed with '_'

Signed-off-by: Nicola Sella <nsella@redhat.com>
More on why it is bad here:
https://docs.astral.sh/ruff/rules/redefined-loop-name/

Signed-off-by: Nicola Sella <nsella@redhat.com>
Signed-off-by: Nicola Sella <nsella@redhat.com>
This is a quality of life improvement and it should be backward
compatible with our previous set line-length

Signed-off-by: Nicola Sella <nsella@redhat.com>
Copy link
Contributor

openshift-ci bot commented Dec 11, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: inknos

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@inknos inknos mentioned this pull request Dec 10, 2024
18 tasks
@inknos inknos changed the title Use pyproject toml and enable workflow for publishing on PyPI [wip] Use pyproject toml and enable workflow for publishing on PyPI Dec 11, 2024
@inknos inknos force-pushed the use-pyproject-toml branch from 92e8d38 to 81bf1b5 Compare December 11, 2024 15:46
@inknos inknos force-pushed the use-pyproject-toml branch from 81bf1b5 to 7e29630 Compare December 11, 2024 15:47
@inknos inknos force-pushed the use-pyproject-toml branch 3 times, most recently from c26888d to 257b46a Compare December 11, 2024 16:16
@inknos
Copy link
Contributor Author

inknos commented Dec 11, 2024

Some errors from building python-podman might go away if we rebase onto #476 as typing_extensions.py is going away.

So I am trying to rebase onto these commits now although the only important ones are the last two at the moment

@inknos inknos force-pushed the use-pyproject-toml branch from 257b46a to dcf1909 Compare December 11, 2024 16:31
Fix sys.version_info comparisons and drop unsupported python code

Furthermore, addresses UP008: super-call-with-parameters

Super is not called with parameters anymore when the first argument is
__class__ and the second argument is equivalent to the first argument of
the enclosing method

Signed-off-by: Nicola Sella <nsella@redhat.com>
It is recommended to use 2 or more to give the caller more context about
warning

Signed-off-by: Nicola Sella <nsella@redhat.com>
B024: abstract-base-class-without-abstract-method
PodmanResource is not an abstract class and the ABC inheritance should be removed

Signed-off-by: Nicola Sella <nsella@redhat.com>
Bugbear checks usually check for design problems within the code.

https://pypi.org/project/flake8-bugbear/

Signed-off-by: Nicola Sella <nsella@redhat.com>
This could be an exception and should be checked in the future but it is
suppressed at the moment.

Signed-off-by: Nicola Sella <nsella@redhat.com>
S603: subprocess-without-shell-equals-true

This could be an exception or a false positive and since it's used on
one single piece of code it is ok to ignore from now.

Signed-off-by: Nicola Sella <nsella@redhat.com>
Bandit provides security checks and good practices suggestions for the
codebase.

https://pypi.org/project/flake8-bandit/

Signed-off-by: Nicola Sella <nsella@redhat.com>
Signed-off-by: Nicola Sella <nsella@redhat.com>
Fix errors for tyope annotation for list, dict, type and tuple

Example:
UP006: Use `list` instead of `List` for type annotation

Signed-off-by: Nicola Sella <nsella@redhat.com>
Python Version is already set to be < 3.9 so this code will never run

Signed-off-by: Nicola Sella <nsella@redhat.com>
Signed-off-by: Nicola Sella <nsella@redhat.com>
This suppresses A003 for `list` builtin.

`typing.List`, `typing.Dict`, `typing.Tuple` and `typing.Type` are
deprecated. Removing these annotations breaks the calls to `list` when
they are done within the same class scope, which makes them ambiguous.

Typed returns `list` resolve to the function `list` defined in the class,
shadowing the builtin function. This change is not great but a proper
one would require changing the name of the class function `list` and
breaking the API to be fixed.

Example of where it breaks:

podman/domains/images_manager.py

class ImagesManager(...):

    def list(...):
        ...

    def pull(
        self,
        ...
        ) -> Image | list[Image], [[str]]:
        ...

Here, the typed annotation of `pull` would resolve to the `list` method,
rather than the builtin.

Signed-off-by: Nicola Sella <nsella@redhat.com>
Signed-off-by: Nicola Sella <nsella@redhat.com>
Signed-off-by: Nicola Sella <nsella@redhat.com>
Signed-off-by: Nicola Sella <nsella@redhat.com>
@inknos inknos force-pushed the use-pyproject-toml branch from dcf1909 to 309c0ca Compare December 11, 2024 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants