Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#1667)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/psf/black: 24.1.1 → 24.2.0](psf/black@24.1.1...24.2.0)
- [github.com/asottile/pyupgrade: v3.15.0 → v3.15.1](asottile/pyupgrade@v3.15.0...v3.15.1)

* Exempt flake8 E501 + let black do it's thing

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Cooper Ry Lees <[email protected]>
  • Loading branch information
pre-commit-ci[bot] and cooperlees authored Mar 5, 2024
1 parent 98578bf commit 0197349
Show file tree
Hide file tree
Showing 10 changed files with 175 additions and 139 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ max_line_length = 88
# E722 is a duplicate of B001.
# P207 is a duplicate of B003.
# W503 is against PEP8
ignore = E203, E704, E722, P207, W503
ignore = E203, E501, E704, E722, P207, W503
max-complexity = 20
exclude =
build,
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ repos:
exclude: ^docs/conf.py$

- repo: https://github.com/psf/black
rev: 24.1.1
rev: 24.2.0
hooks:
- id: black
args: [--target-version, py38, --preview]

- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
rev: v3.15.1
hooks:
- id: pyupgrade
args: [--py310-plus]
Expand Down
36 changes: 20 additions & 16 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,15 @@ class DocStub:
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [(
"index",
doc_module.__name__ + ".tex",
doc_module.__name__ + " Documentation",
"PyPA",
"manual",
)]
latex_documents = [
(
"index",
doc_module.__name__ + ".tex",
doc_module.__name__ + " Documentation",
"PyPA",
"manual",
)
]

# The name of an image file (relative to this directory) to place at the top of
# the title page.
Expand Down Expand Up @@ -260,15 +262,17 @@ class DocStub:
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [(
"index",
doc_module.__name__,
doc_module.__name__ + " Documentation",
"",
doc_module.__name__,
doc_module.__name__ + " Documentation",
"Miscellaneous",
)]
texinfo_documents = [
(
"index",
doc_module.__name__,
doc_module.__name__ + " Documentation",
"",
doc_module.__name__,
doc_module.__name__ + " Documentation",
"Miscellaneous",
)
]

# Documents to append as an appendix to all manuals.
# texinfo_appendices = []
Expand Down
10 changes: 6 additions & 4 deletions src/bandersnatch/mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,10 +493,12 @@ def _bootstrap(self, flock_timeout: float = 1.0) -> None:
]
if self.json_save:
logger.debug("Adding json directories to bootstrap")
paths.extend([
self.storage_backend.PATH_BACKEND("web/json"),
self.storage_backend.PATH_BACKEND("web/pypi"),
])
paths.extend(
[
self.storage_backend.PATH_BACKEND("web/json"),
self.storage_backend.PATH_BACKEND("web/pypi"),
]
)
for path in paths:
path = self.homedir / path
if not path.exists():
Expand Down
56 changes: 32 additions & 24 deletions src/bandersnatch/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,13 @@ def find_packages_in_dir(self, simple_dir: Path) -> list[str]:
"""Given a directory that contains simple packages indexes, return
a sorted list of normalized package names. This presumes every
directory within is a simple package index directory."""
return sorted({
str(x.name) for x in self.storage_backend.scandir(simple_dir) if x.is_dir()
})
return sorted(
{
str(x.name)
for x in self.storage_backend.scandir(simple_dir)
if x.is_dir()
}
)

def gen_html_file_tags(self, release: dict) -> str:
file_tags = ""
Expand Down Expand Up @@ -183,16 +187,18 @@ def generate_html_simple_page(self, package: Package) -> str:

digest_name = self.digest_name

simple_page_content += "\n".join([
' <a href="{}#{}={}"{}>{}</a><br/>'.format(
self._file_url_to_local_url(r["url"]),
digest_name,
r["digests"][digest_name],
self.gen_html_file_tags(r),
r["filename"],
)
for r in release_files
])
simple_page_content += "\n".join(
[
' <a href="{}#{}={}"{}>{}</a><br/>'.format(
self._file_url_to_local_url(r["url"]),
digest_name,
r["digests"][digest_name],
self.gen_html_file_tags(r),
r["filename"],
)
for r in release_files
]
)

simple_page_content += (
f"\n </body>\n</html>\n<!--SERIAL {package.last_serial}-->"
Expand All @@ -219,17 +225,19 @@ def generate_json_simple_page(

# Add release files into the JSON dict
for r in release_files:
package_json["files"].append({
"filename": r["filename"],
"hashes": {
self.digest_name: r["digests"][self.digest_name],
},
"requires-python": r.get("requires_python", ""),
"size": r["size"],
"upload-time": r.get("upload_time_iso_8601", ""),
"url": self._file_url_to_local_url(r["url"]),
"yanked": r.get("yanked", False),
})
package_json["files"].append(
{
"filename": r["filename"],
"hashes": {
self.digest_name: r["digests"][self.digest_name],
},
"requires-python": r.get("requires_python", ""),
"size": r["size"],
"upload-time": r.get("upload_time_iso_8601", ""),
"url": self._file_url_to_local_url(r["url"]),
"yanked": r.get("yanked", False),
}
)

if pretty:
return json.dumps(package_json, indent=4)
Expand Down
12 changes: 7 additions & 5 deletions src/bandersnatch/tests/plugins/test_filename.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,13 @@ def test_exclude_platform(self) -> None:
"flag": "DROP",
},
],
"0.2": [{
"packagetype": "bdist_egg",
"filename": "foobar-0.1-freebsd-6.0-RELEASE-i386.egg",
"flag": "DROP",
}],
"0.2": [
{
"packagetype": "bdist_egg",
"filename": "foobar-0.1-freebsd-6.0-RELEASE-i386.egg",
"flag": "DROP",
}
],
"0.3": [
{
"packagetype": "bdist_wheel",
Expand Down
13 changes: 8 additions & 5 deletions src/bandersnatch/tests/plugins/test_storage_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -942,11 +942,14 @@ def test_get_hash(self) -> None:

class TestFilesystemStoragePlugin(BaseStoragePluginTestCase):
backend = "filesystem"
base_find_contents = "\n".join([
line
for line in BaseStoragePluginTestCase.base_find_contents.split("\n")
if "web{0}local-stats{0}days{0}.swiftkeep".format(os.path.sep) != line.strip()
])
base_find_contents = "\n".join(
[
line
for line in BaseStoragePluginTestCase.base_find_contents.split("\n")
if "web{0}local-stats{0}days{0}.swiftkeep".format(os.path.sep)
!= line.strip()
]
)


class TestSwiftStoragePlugin(BaseStoragePluginTestCase):
Expand Down
44 changes: 24 additions & 20 deletions src/bandersnatch/tests/test_mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,30 @@ def iter_content(*args: Any, **kwargs: Any) -> Iterator[bytes]:


# master.get() returned data needs to have a .json() method and iter_content
FAKE_RELEASE_DATA = JsonDict({
"info": {"name": "foo", "version": "0.1"},
"last_serial": 654_321,
"releases": {
"0.1": [{
"url": "https://pypi.example.com/packages/any/f/foo/foo.zip",
"filename": "foo.zip",
"digests": {
"md5": "ebdad75ed9a852bbfd9be4c18bf76d00",
"sha256": (
"746e6da7eda8b75af9acbdd29808473df08a00362981f0949023e387da1a4734"
),
},
"md5_digest": "ebdad75ed9a852bbfd9be4c18bf76d00",
"packagetype": "sdist",
"size": 1234,
"upload_time_iso_8601": "2000-01-01T01:23:45.123456Z",
}]
},
})
FAKE_RELEASE_DATA = JsonDict(
{
"info": {"name": "foo", "version": "0.1"},
"last_serial": 654_321,
"releases": {
"0.1": [
{
"url": "https://pypi.example.com/packages/any/f/foo/foo.zip",
"filename": "foo.zip",
"digests": {
"md5": "ebdad75ed9a852bbfd9be4c18bf76d00",
"sha256": (
"746e6da7eda8b75af9acbdd29808473df08a00362981f0949023e387da1a4734"
),
},
"md5_digest": "ebdad75ed9a852bbfd9be4c18bf76d00",
"packagetype": "sdist",
"size": 1234,
"upload_time_iso_8601": "2000-01-01T01:23:45.123456Z",
}
]
},
}
)


def touch_files(paths: list[Path]) -> None:
Expand Down
100 changes: 53 additions & 47 deletions src/bandersnatch/tests/test_simple_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,57 @@
},
"last_serial": 10333928,
"releases": {
"0.69": [{
"comment_text": "",
"digests": {
"md5": "4328d962656395fbd3e730c9d30bb48c",
"sha256": (
"5c11f48399f9b1bca802751513f1f97bff6ce97e6facb576b7729e1351453c10"
),
},
"downloads": -1,
"filename": "69-0.69.tar.gz",
"has_sig": False,
"md5_digest": "4328d962656395fbd3e730c9d30bb48c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 1078,
"upload_time": "2018-05-17T03:37:19",
"upload_time_iso_8601": "2018-05-17T03:37:19.330556Z",
"url": "https://files.pythonhosted.org/packages/d3/cc/95dc5434362bd333a1fec275231775d748315b26edf1e7e568e6f8660238/69-0.69.tar.gz",
"yanked": False,
"yanked_reason": None,
}],
"6.9": [{
"0.69": [
{
"comment_text": "",
"digests": {
"md5": "4328d962656395fbd3e730c9d30bb48c",
"sha256": (
"5c11f48399f9b1bca802751513f1f97bff6ce97e6facb576b7729e1351453c10"
),
},
"downloads": -1,
"filename": "69-0.69.tar.gz",
"has_sig": False,
"md5_digest": "4328d962656395fbd3e730c9d30bb48c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 1078,
"upload_time": "2018-05-17T03:37:19",
"upload_time_iso_8601": "2018-05-17T03:37:19.330556Z",
"url": "https://files.pythonhosted.org/packages/d3/cc/95dc5434362bd333a1fec275231775d748315b26edf1e7e568e6f8660238/69-0.69.tar.gz",
"yanked": False,
"yanked_reason": None,
}
],
"6.9": [
{
"comment_text": "",
"digests": {
"md5": "ff4bf804ef3722a1fd8853a8a32513d4",
"sha256": (
"0c8deb7c8574787283c3fc08b714ee63fd6752a38d13515a9d8508798d428597"
),
},
"downloads": -1,
"filename": "69-6.9.tar.gz",
"has_sig": False,
"md5_digest": "ff4bf804ef3722a1fd8853a8a32513d4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 1077,
"upload_time": "2018-05-17T03:47:45",
"upload_time_iso_8601": "2018-05-17T03:47:45.953704Z",
"url": "https://files.pythonhosted.org/packages/7b/6e/7c4ce77c6ca092e94e19b78282b459e7f8270362da655cbc6a75eeb9cdd7/69-6.9.tar.gz",
"yanked": False,
"yanked_reason": None,
}
],
},
"urls": [
{
"comment_text": "",
"digests": {
"md5": "ff4bf804ef3722a1fd8853a8a32513d4",
Expand All @@ -79,30 +107,8 @@
"url": "https://files.pythonhosted.org/packages/7b/6e/7c4ce77c6ca092e94e19b78282b459e7f8270362da655cbc6a75eeb9cdd7/69-6.9.tar.gz",
"yanked": False,
"yanked_reason": None,
}],
},
"urls": [{
"comment_text": "",
"digests": {
"md5": "ff4bf804ef3722a1fd8853a8a32513d4",
"sha256": (
"0c8deb7c8574787283c3fc08b714ee63fd6752a38d13515a9d8508798d428597"
),
},
"downloads": -1,
"filename": "69-6.9.tar.gz",
"has_sig": False,
"md5_digest": "ff4bf804ef3722a1fd8853a8a32513d4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 1077,
"upload_time": "2018-05-17T03:47:45",
"upload_time_iso_8601": "2018-05-17T03:47:45.953704Z",
"url": "https://files.pythonhosted.org/packages/7b/6e/7c4ce77c6ca092e94e19b78282b459e7f8270362da655cbc6a75eeb9cdd7/69-6.9.tar.gz",
"yanked": False,
"yanked_reason": None,
}],
}
],
"vulnerabilities": [],
}

Expand Down
Loading

0 comments on commit 0197349

Please sign in to comment.