Commit graph

26 commits

Author SHA1 Message Date
Jussi Kukkonen
88cc98420e lint fixes
Fixes for ruff 0.12
* Tweak some annotations
* Add __hash__() implementations to api classes: These really should be
  hashable
* My use of "super().__hash__()" is not very optimized but avoids some
  repetition

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
2025-06-24 11:02:09 +03:00
Jussi Kukkonen
73273813f3
Merge pull request #2773 from jku/no-requests
More porting from  requests to urllib3
2025-02-20 08:51:42 +00:00
pakagronglb
94639360ec Enable FA (future annotations) linting ruleset
Signed-off-by: pakagronglb <pakagronglebel@gmail.com>
2025-02-19 19:44:05 +07:00
Jussi Kukkonen
cfee40aa96 More porting from from requests to urllib3
This is related to #2762 (that replaces RequestsFetcher with
Urllib3Fetcher) and takes care of the remaining requests use cases in
the code base.

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
2025-02-14 17:41:50 +02:00
Jussi Kukkonen
4244632a2f lint: Enable pygrep-hooks
Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
2024-05-06 09:19:19 +03:00
E3E
52601e2bd8 add RUF and BLE rulesets; ignore some broad exceptions (BLE001) and RUF012
Signed-off-by: E3E <ntanzill@purdue.edu>
2024-04-21 01:37:40 -04:00
Jussi Kukkonen
009566aa23 lint: Start using ruff ruleset "flake8-bandit"
* Remove bandit
* Add ruff ruleset "flake8-bandit"
* verify_release is now checked by bandit
  * Avoid some asserts as suggested
  * ignore a subprocess.run lint: it seems dumb
* ignore all bandit rules for tests and examples (just like before)

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
2024-02-23 18:27:29 +02:00
E3E
73842c97b8 reformat docstrings and supress small errors inline
Signed-off-by: E3E <ntanzill@purdue.edu>
2024-02-20 15:19:33 -05:00
E3E
1a4d870aad add back in: # type: ignore
Signed-off-by: E3E <ntanzill@purdue.edu>
2024-02-20 00:44:58 -05:00
E3E
206c9424f1 Add to linting Configuration:
- adpot changes in dependabot.yml and remove --diff from ruff check.
- select pydocstyle, isort, pyflakes, pep8-naming, pycodestyle for ruff and ignore some small issues / add inline comments.
- adjust docstring length to 80 in various files

Signed-off-by: E3E <ntanzill@purdue.edu>
2024-02-20 00:34:47 -05:00
Lukas Puehringer
73cf25efe8 build: constrain version in verify_release script
In #2528 we added a workaround in cd.yml, which allows pinning the
build backend version AND having Dependabot autodupates for it.

This workaround also needs to be applied verify_release for reproducible
builds verification.

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
2024-01-11 16:26:29 +01:00
Abu Talha
21ed19c264 verify_release: PEP 484 compliant annotations
Signed-off-by: Abu Talha <itsabutalha@gmail.com>
2022-11-21 06:41:17 +00:00
Joshua Lock
4c8e965169 verify_release: do a deep comparison of the files
dircmp[1] does a shallow[2] comparison of files, that is only the file
type, size and modification time are compared -- not the file size or
contents. Therefore, switch to using cmp with the shallow option set to
False to perform a full comparison of the local files and retrieved files.

1. https://docs.python.org/3/library/filecmp.html?filecmp.dircmp#filecmp.dircmp
2. https://docs.python.org/3/library/filecmp.html?filecmp.dircmp#filecmp.cmp

Signed-off-by: Joshua Lock <jlock@vmware.com>
2022-09-29 20:47:21 +01:00
Lukas Puehringer
7b9cf4ac8e verify_release: add constant 5s HTTP timeout
Add 5 seconds HTTP timeout constant and use it for requests to
GitHub. Setting timeout is recommended by requests docs and flagged
by latest pylint:
```
W3101: Missing timeout argument for method 'requests.get' can cause
your program to hang indefinitely (missing-timeout)
```
https://requests.readthedocs.io/en/latest/user/quickstart/#timeouts

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
2022-08-30 09:06:17 +02:00
Jussi Kukkonen
96232d2db0 verify_release: Tweak pip download
It seems --no-deps does not work as it used to (and actually installs
all build dependencies). This is very bad because verify_release also
uses "--no-binary :all:" leading to actually _building_ all build
dependencies from source.

Use "--no-binary tuf" instead: build dependencies will still be
installed (into a working environment) but at least they won't be built
from source.

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2022-04-27 17:54:36 +03:00
Lukas Pühringer
a3d5a37e43 build: minor style/wording fixes in verify_release
Co-authored-by: Joshua Lock <jlock@vmware.com>
Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
2022-04-27 13:09:48 +02:00
Lukas Puehringer
e56ff07b1a build: add 'gpg sign' option to verify_release
Add option to sign locally built release artifacts with gpg,
if they match the downloaded artifacts from GitHub, PyPI.

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
2022-04-27 12:47:15 +02:00
Lukas Puehringer
e7544bfbe7 build: fix success message in verify_release
Prior to #1946 the verify_release script was successful if both PyPI
and GitHub release artifacts matched the local build.

Now, if the `--skip-pypi` option is provided, the script can also
be successful if only the GitHub release artifacts match the local
build.

This commit splits the final success message in two separate
success messages, one for PyPI and one for GitHub.

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
2022-04-27 12:34:07 +02:00
Lukas Pühringer
72424a958b
Merge pull request #1946 from lukpueh/auto-release
Add GH workflow to build and release on GH and PyPI
2022-04-21 13:03:25 +02:00
Jussi Kukkonen
62580abf9c verify_release: Build from git sources only
Make a new (local) git clone to build from. This ensures uncommitted
files do not affect the build.

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2022-04-08 16:54:02 +03:00
Lukas Puehringer
4f275ad636 build: add skip-pypi flag to verify_release script
Add '--skip-pypi' flag to 'verify_release' script to allow for
pre-release checks, when the automatic build job has uploaded the
build assets to GitHub and is awaiting review/approval in order to
upload it to PyPI eventually.

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
2022-04-07 12:16:00 +02:00
Lukas Puehringer
a76ed28c02 build: lint 'verify_release' with tox
Enable tox to lint 'verify_release' script and fix:
- whitespace
- unused import (we only import here to see if the module is
  available for use in a subprocess)
- unfound import (same as unused import)

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
2022-04-07 12:16:00 +02:00
Jussi Kukkonen
bf878ceaa6 verify_release: Warn about missing requirements
This is mostly useful for build module as it's not imported otherwise:
we explicitly call "python -m build" so everything works like in a
real release build.

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2022-03-25 11:50:15 +02:00
Jussi Kukkonen
6819d4174a verify_release: Be specific about expected artifacts
Use a hard-coded list of artifacts that we expect to find in a
release. Specifically check that each of those files matches
the corresponding file in locally built release.

Also add two missing annotations.

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2022-03-24 14:39:59 +02:00
Jussi Kukkonen
65d6503e63 verify_release: Be explicit about PyPI version
We are interested in what pip thinks is the current tuf version: make
that explicit in method naming and comments.

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2022-03-23 15:22:27 +02:00
Jussi Kukkonen
53bacdf7e3 build: Add verify-release script
verify-release
* Builds a release from current commit
* Notifies if git describe does not match built version
* Notifies if built version is not the latest GitHub or PyPI version
* Asserts that the GitHub and PyPI release artifacts match the built
  release artifacts

This should be useful after release as any developer (or a CI job) can
easily verify that the release matches the sources in git.

Note that the last checks currently fail as the 1.0 build was not
reproducible. They should succeed after next release.

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2022-03-22 14:47:17 +02:00