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

Update Black to 24.3.0 #868

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
default_stages: [commit]
repos:
- repo: https://github.com/ambv/black
rev: 22.3.0
rev: 24.3.0
hooks:
- id: black
language_version: python3
Expand Down
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ verify_ssl = true
ggshield = { editable = true, path = "." }

[dev-packages]
black = "==22.3.0"
black = "==24.3.0"
coverage = "*"
flake8 = "*"
flake8-isort = "*"
Expand Down
58 changes: 29 additions & 29 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions ggshield/cmd/iac/scan/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ def iac_scan_all(
scan_parameters,
ScanContext(
command_path=ctx.command_path,
scan_mode=scan_mode
if ci_mode is None
else f"{scan_mode.value}/{ci_mode.value}",
scan_mode=(
scan_mode if ci_mode is None else f"{scan_mode.value}/{ci_mode.value}"
),
extra_headers={"Ci-Mode": str(ci_mode.value)} if ci_mode else None,
target_path=directory,
).get_http_headers(),
Expand Down
6 changes: 3 additions & 3 deletions ggshield/cmd/iac/scan/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ def iac_scan_diff(
scan_parameters,
ScanContext(
command_path=ctx.command_path,
scan_mode=scan_mode
if ci_mode is None
else f"{scan_mode.value}/{ci_mode.value}",
scan_mode=(
scan_mode if ci_mode is None else f"{scan_mode.value}/{ci_mode.value}"
),
extra_headers={"Ci-Mode": str(ci_mode.value)} if ci_mode else None,
target_path=directory,
).get_http_headers(),
Expand Down
1 change: 1 addition & 0 deletions ggshield/cmd/iac/scan/iac_scan_common_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
The `kwargs` argument is required due to the way click works,
`add_common_options()` adds an argument for each option it defines.
"""

from typing import Any, Callable, Sequence

import click
Expand Down
1 change: 1 addition & 0 deletions ggshield/cmd/sca/scan/scan_common_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
The `kwargs` argument is required due to the way click works,
`add_common_options()` adds an argument for each option it defines.
"""

from typing import Callable, Sequence

import click
Expand Down
1 change: 1 addition & 0 deletions ggshield/cmd/utils/common_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
The `kwargs` argument is required because due to the way click works,
`add_common_options()` adds an argument for each option it defines.
"""

from pathlib import Path
from typing import Any, Callable, Optional, TypeVar

Expand Down
6 changes: 2 additions & 4 deletions ggshield/core/config/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,11 @@ def get_global_path(filename: str) -> Path:


@overload
def find_global_config_path(*, to_write: Literal[False] = False) -> Optional[Path]:
...
def find_global_config_path(*, to_write: Literal[False] = False) -> Optional[Path]: ...


@overload
def find_global_config_path(*, to_write: Literal[True]) -> Path:
...
def find_global_config_path(*, to_write: Literal[True]) -> Path: ...


def find_global_config_path(*, to_write: bool = False) -> Optional[Path]:
Expand Down
1 change: 1 addition & 0 deletions ggshield/core/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This module centralizes GGShield error handling. For more details, have a look
at doc/dev/error-handling.md.
"""

import platform
import traceback
from enum import IntEnum
Expand Down
8 changes: 5 additions & 3 deletions ggshield/core/scan/scan_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ def get_http_headers(self) -> Dict[str, str]:

return {
**{f"GGShield-{key}": str(value) for key, value in headers.items()},
"mode": self.scan_mode.value
if isinstance(self.scan_mode, ScanMode)
else self.scan_mode,
"mode": (
self.scan_mode.value
if isinstance(self.scan_mode, ScanMode)
else self.scan_mode
),
}
2 changes: 1 addition & 1 deletion ggshield/utils/git_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def simplify_git_url(url: str) -> str:
- extension
https://user:pass@mygitlab.corp.com:84/path/to/repo.git -> mygitlab.corp.com/toto/titi/tata
"""
for (pattern, replace) in (
for pattern, replace in (
(r"https?://", ""), # Scheme
(r".+@", ""), # Credentials
(r":\d*/", "/"), # Port
Expand Down
18 changes: 6 additions & 12 deletions ggshield/utils/os.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,11 @@ def cd(newdir: Union[str, Path]) -> Iterator[None]:


@overload
def getenv_int(key: str, default: None = None) -> Optional[int]:
...
def getenv_int(key: str, default: None = None) -> Optional[int]: ...


@overload
def getenv_int(key: str, default: int) -> int:
...
def getenv_int(key: str, default: int) -> int: ...


def getenv_int(key: str, default: Optional[int] = None) -> Optional[int]:
Expand All @@ -84,13 +82,11 @@ def getenv_int(key: str, default: Optional[int] = None) -> Optional[int]:


@overload
def getenv_float(key: str, default: None = None) -> Optional[float]:
...
def getenv_float(key: str, default: None = None) -> Optional[float]: ...


@overload
def getenv_float(key: str, default: float) -> float:
...
def getenv_float(key: str, default: float) -> float: ...


def getenv_float(key: str, default: Optional[float] = None) -> Optional[float]:
Expand All @@ -101,13 +97,11 @@ def getenv_float(key: str, default: Optional[float] = None) -> Optional[float]:


@overload
def getenv_bool(key: str, default: None = None) -> Optional[bool]:
...
def getenv_bool(key: str, default: None = None) -> Optional[bool]: ...


@overload
def getenv_bool(key: str, default: bool) -> bool:
...
def getenv_bool(key: str, default: bool) -> bool: ...


def getenv_bool(key: str, default: Optional[bool] = None) -> Optional[bool]:
Expand Down
8 changes: 5 additions & 3 deletions ggshield/verticals/iac/output/iac_text_output_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,11 @@ def label_incident(n: int) -> str:
format_text(
f"[~] {num_unchanged} {label_incident(num_unchanged)} remaining",
STYLE[
"iac_remaining_vulnerability"
if num_unchanged > 0
else "iac_dim_summary"
(
"iac_remaining_vulnerability"
if num_unchanged > 0
else "iac_dim_summary"
)
],
)
)
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ console_scripts = ggshield=ggshield.__main__:main
[flake8]
inline-quotes = double
max-line-length = 120
ignore = E203, W503
ignore = E203, E704, W503
exclude = **/snapshots/*.py, .venv, build