Skip to content

Commit

Permalink
Update pre-commit dependencies (#353)
Browse files Browse the repository at this point in the history
* Update pre-commit dependencies

* Fix `flake8` errors (two typos in var names)

* Fix `mypy` importing errors

* Fix `mypy` code errors

* Update `conda/dev.yml`
  • Loading branch information
altheaden authored Oct 14, 2024
1 parent ef8372a commit 082afc7
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 24 deletions.
18 changes: 12 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,41 @@ fail_fast: true

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
exclude: conda/meta.yaml

- repo: https://github.com/psf/black
rev: 22.3.0
rev: 24.10.0
hooks:
- id: black

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort

# Need to use flake8 GitHub mirror due to CentOS git issue with GitLab
# https://github.com/pre-commit/pre-commit/issues/1206
- repo: https://github.com/pycqa/flake8
rev: 3.8.4
rev: 7.1.1
hooks:
- id: flake8
args: ["--config=setup.cfg"]
additional_dependencies: [flake8-isort]
exclude: analysis_data_preprocess

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.790
rev: v1.11.2
hooks:
- id: mypy
args: ["--config=setup.cfg"]
args: ["--config=setup.cfg", "--install-types", "--non-interactive"]
exclude: test*

# https://pre-commit.ci/#configuration
ci:
autofix_prs: false
autoupdate_schedule: monthly
10 changes: 5 additions & 5 deletions conda/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ dependencies:
# Developer Tools
# =================
# If versions are updated, also update 'rev' in `.pre-commit.config.yaml`
- black=22.8.0
- flake8=5.0.4
- flake8-isort=4.2.0
- mypy=0.982
- pre-commit=2.20.0
- black=24.10.0
- flake8=7.1.1
- flake8-isort=6.1.1
- mypy=1.11.2
- pre-commit=4.0.1
- tbump=6.9.0
# Documentation
# =================
Expand Down
1 change: 0 additions & 1 deletion zstash/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

def create():
cache: str
exclude: str
cache, args = setup_create()

# Check config fields
Expand Down
14 changes: 6 additions & 8 deletions zstash/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def extract_database(
# This is because we may have different versions of the
# same file across many tars.
insert_idx: int
iter_inx: int
iter_idx: int
insert_idx, iter_idx = 0, 1
for iter_idx in range(1, len(matches)):
# If the filenames are unique, just increment insert_idx.
Expand Down Expand Up @@ -351,10 +351,10 @@ def multiprocess_extract(
for db_row in matches:
tar = db_row.tar
workers_idx: int
for worker_idx in range(len(workers_to_tars)):
if tar in workers_to_tars[worker_idx]:
for workers_idx in range(len(workers_to_tars)):
if tar in workers_to_tars[workers_idx]:
# This worker gets this db_row.
workers_to_matches[worker_idx].append(db_row)
workers_to_matches[workers_idx].append(db_row)

tar_ordering: List[str] = sorted([tar for tar in tar_to_size])
monitor: parallel.PrintMonitor = parallel.PrintMonitor(tar_ordering)
Expand Down Expand Up @@ -444,8 +444,7 @@ def extractFiles( # noqa: C901
if multiprocess_worker:
# All messages to the logger will now be sent to
# this queue, instead of sys.stdout.
# error: Argument 1 to "StreamHandler" has incompatible type "PrintQueue"; expected "Optional[IO[str]]"
sh = logging.StreamHandler(multiprocess_worker.print_queue) # type: ignore
sh = logging.StreamHandler(multiprocess_worker.print_queue)
sh.setLevel(logging.DEBUG)
formatter: logging.Formatter = logging.Formatter("%(levelname)s: %(message)s")
sh.setFormatter(formatter)
Expand Down Expand Up @@ -539,8 +538,7 @@ def extractFiles( # noqa: C901
# error: Name 'tarfile.ExFileObject' is not defined
extracted_file: Optional[tarfile.ExFileObject] = tar.extractfile(tarinfo) # type: ignore
if extracted_file:
# error: Name 'tarfile.ExFileObject' is not defined
fin: tarfile.ExFileObject = extracted_file # type: ignore
fin: tarfile.ExFileObject = extracted_file
else:
raise TypeError("Invalid extracted_file={}".format(extracted_file))
try:
Expand Down
6 changes: 2 additions & 4 deletions zstash/hpss_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ def add_file(
tar: tarfile.TarFile, file_name: str, follow_symlinks: bool
) -> Tuple[int, int, datetime, Optional[str]]:

# FIXME: error: "TarFile" has no attribute "offset"
offset: int = tar.offset # type: ignore
offset: int = tar.offset
tarinfo: tarfile.TarInfo = tar.gettarinfo(file_name)
# Change the size of any hardlinks from 0 to the size of the actual file
if tarinfo.islnk():
Expand Down Expand Up @@ -215,8 +214,7 @@ def add_file(
fileobj.write(null_bytes * (tarfile.BLOCKSIZE - remainder))
blocks += 1
# Increase the offset by the amount already saved to the tar
# FIXME: error: "TarFile" has no attribute "offset"
tar.offset += blocks * tarfile.BLOCKSIZE # type: ignore
tar.offset += blocks * tarfile.BLOCKSIZE
break
f.close()
md5 = hash_md5.hexdigest()
Expand Down

0 comments on commit 082afc7

Please sign in to comment.