Skip to content

Commit

Permalink
ruff: S (#1027)
Browse files Browse the repository at this point in the history
  • Loading branch information
Borda committed May 31, 2023
1 parent 2d61e05 commit ba6b4c6
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ repos:
- id: yesqa
additional_dependencies:
- flake8-pytest-style
- flake8-bandit

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.270
Expand Down
14 changes: 12 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ select = [
"RET", # see: https://pypi.org/project/flake8-return
"SIM", # see: https://pypi.org/project/flake8-simplify
"YTT", # see: https://pypi.org/project/flake8-2020
# "ANN", # see: https://pypi.org/project/flake8-annotations
# "S", # see: https://pypi.org/project/flake8-bandit
"S", # see: https://pypi.org/project/flake8-bandit
"T10", # see: https://pypi.org/project/flake8-debugger/
# "ANN", # see: https://pypi.org/project/flake8-annotations
]
ignore = [
"E731", # Do not assign a lambda expression, use a def
Expand All @@ -96,6 +96,16 @@ exclude = [
ignore-init-module-imports = true
unfixable = ["F401"]

[tool.ruff.per-file-ignores]
"src/**" = [
"S101", # todo: Use of `assert` detected
"S324", # todo: Probable use of insecure hash functions in `hashlib`: `md5`

]
"tests/**" = [
"S101", # Use of `assert` detected
]

[tool.mypy]
files = ["src/pl_bolts"]
disallow_untyped_defs = "True"
Expand Down
2 changes: 1 addition & 1 deletion src/pl_bolts/datasets/base_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def _download_from_url(self, base_url: str, data_folder: str, file_name: str):
logging.info(f"Downloading {url}")
fpath = os.path.join(data_folder, file_name)
try:
urllib.request.urlretrieve(url, fpath)
urllib.request.urlretrieve(url, fpath) # noqa: S310
except HTTPError as err:
raise RuntimeError(f"Failed download from {url}") from err

Expand Down
2 changes: 1 addition & 1 deletion src/pl_bolts/datasets/cifar10_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def _check_exists(cls, data_folder: str, file_names: Sequence[str]) -> bool:

def _unpickle(self, path_folder: str, file_name: str) -> Tuple[Tensor, Tensor]:
with open(os.path.join(path_folder, file_name), "rb") as fo:
pkl = pickle.load(fo, encoding="bytes")
pkl = pickle.load(fo, encoding="bytes") # noqa: S301
return torch.tensor(pkl[b"data"]), torch.tensor(pkl[b"labels"])

def _extract_archive_save_torch(self, download_path):
Expand Down
2 changes: 1 addition & 1 deletion src/pl_bolts/transforms/self_supervised/moco_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,6 @@ def __init__(self, sigma: List[float] = [0.1, 2.0]) -> None:
self.sigma = sigma

def __call__(self, x):
sigma = random.uniform(self.sigma[0], self.sigma[1])
sigma = random.uniform(self.sigma[0], self.sigma[1]) # noqa: S311
x = x.filter(ImageFilter.GaussianBlur(radius=sigma))
return x

0 comments on commit ba6b4c6

Please sign in to comment.