Skip to content

Commit 8d836ef

Browse files
authored
Merge pull request #44 from GitGuardian/plalanne/43/fix-dependencies
Fix missing dependencies in the package
2 parents 183784d + 795c584 commit 8d836ef

File tree

5 files changed

+20
-15
lines changed

5 files changed

+20
-15
lines changed

Pipfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ url = "https://pypi.python.org/simple"
44
verify_ssl = true
55

66
[packages]
7-
marshmallow = ">=3.5"
87
pygitguardian = { editable = true, path = "." }
9-
requests = ">=2"
10-
marshmallow-dataclass = ">=8.5.8,<8.6.0"
118

129
[dev-packages]
1310
black = "==22.3.0"

pygitguardian/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
"""PyGitGuardian API Client"""
2-
from .client import GGClient
2+
from .client import ContentTooLarge, GGClient
33

44

55
__version__ = "1.5.0"
66
GGClient._version = __version__
77

8-
__all__ = [
9-
"GGClient",
10-
]
8+
__all__ = ["GGClient", "ContentTooLarge"]

pygitguardian/client.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from pathlib import Path
77
from typing import Any, Dict, List, Optional, Union, cast
88

9-
import click
109
import requests
1110
from requests import Response, Session, codes
1211

@@ -36,6 +35,14 @@
3635
MAX_TAR_CONTENT_SIZE = 30 * 1024 * 1024
3736

3837

38+
class ContentTooLarge(Exception):
39+
"""
40+
Raised if the total size of files sent by the client exceeds MAX_TAR_CONTENT_SIZE
41+
"""
42+
43+
pass
44+
45+
3946
class Versions:
4047
app_version: Optional[str] = None
4148
secrets_engine_version: Optional[str] = None
@@ -86,7 +93,7 @@ def _create_tar(root_path: Path, filenames: List[str]) -> bytes:
8693
full_path = root_path / filename
8794
current_dir_size += os.path.getsize(full_path)
8895
if current_dir_size > MAX_TAR_CONTENT_SIZE:
89-
raise click.ClickException(
96+
raise ContentTooLarge(
9097
f"The total size of the files processed exceeds {MAX_TAR_CONTENT_SIZE / (1024 * 1024):.0f}MB, "
9198
f"please try again with less files"
9299
)
@@ -393,7 +400,6 @@ def iac_directory_scan(
393400
scan_parameters: IaCScanParameters,
394401
extra_headers: Optional[Dict[str, str]] = None,
395402
) -> Union[Detail, IaCScanResult]:
396-
397403
tar = _create_tar(directory, filenames)
398404
result: Union[Detail, IaCScanResult]
399405
try:

setup.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,19 @@ def get_version() -> str:
2424
name="pygitguardian",
2525
version=get_version(),
2626
packages=find_packages(exclude=["tests"]),
27-
description="Python Wrapper for GitGuardian's API -- Scan security policy breaks everywhere",
27+
description="Python Wrapper for GitGuardian's API -- Scan security "
28+
"policy breaks everywhere",
2829
long_description=read("README.md"),
2930
long_description_content_type="text/markdown",
3031
url="https://github.com/GitGuardian/py-gitguardian",
3132
author="GitGuardian",
3233
author_email="[email protected]",
3334
maintainer="GitGuardian",
34-
install_requires=["marshmallow>=3.5", "requests>=2"],
35+
install_requires=[
36+
"marshmallow>=3.5, <4",
37+
"requests>=2, <3",
38+
"marshmallow-dataclass >=8.5.8, <8.6.0",
39+
],
3540
include_package_data=True,
3641
zip_safe=True,
3742
license="MIT",

tests/test_utils.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
from io import BytesIO
33
from unittest import mock
44

5-
import click
65
import pytest
76

8-
from pygitguardian.client import _create_tar
7+
from pygitguardian.client import ContentTooLarge, _create_tar
98

109

1110
def test_create_tar(tmp_path):
@@ -44,7 +43,7 @@ def test_create_tar_cannot_exceed_max_tar_content_size(tmp_path):
4443
(tmp_path / file2_name).write_text("")
4544

4645
with pytest.raises(
47-
click.ClickException,
46+
ContentTooLarge,
4847
match=r"The total size of the files processed exceeds \d+MB, please try again with less files",
4948
):
5049
_create_tar(tmp_path, [file1_name, file2_name])

0 commit comments

Comments
 (0)