Skip to content

Commit 3baac7a

Browse files
committed
code cleanup to prep for release
1 parent 4e4c001 commit 3baac7a

File tree

8 files changed

+25
-61
lines changed

8 files changed

+25
-61
lines changed

.github/workflows/run-pytest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ${{ matrix.os }}
1212
strategy:
1313
matrix:
14-
python-version: ["3.10", "3.13"]
14+
python-version: ["3.10", "3.14"]
1515
os: [ubuntu-latest]
1616

1717
steps:

changelog.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,19 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
77
### Changed
88
- Migrated packaging from setup.py/setup.cfg to pyproject.toml with hatchling backend
99
- Replaced black with ruff for linting and formatting
10-
- Added .pre-commit-config.yaml with ruff
11-
- Updated GitHub Actions workflows to latest versions (checkout@v4, setup-python@v5)
10+
- Updated GitHub Actions workflows to latest versions (checkout@v6, setup-python@v6)
1211
- Updated publish workflow to use `python -m build` instead of `setup.py sdist`
1312
- Modernized type hints: replaced `Optional`/`Union` with PEP 604 `X | None` / `X | Y` syntax
1413
- Converted remaining Sphinx-style docstrings to Google style
1514
- Dropped Python 3.9 support (minimum is now 3.10)
15+
- Added Python 3.14 support
16+
17+
### Fixed
18+
- Deduplicated `mkabs` in `file_locking.py``ThreeLocker` now uses the canonical version from `paths.py` which handles None, URLs, and file-as-reldir
19+
- Deduplicated `_create_lock` in `file_locking.py` — consolidated to single implementation in `files.py`
20+
- Fixed `tarfile.extractall()` deprecation warning for Python 3.12+ (added `filter="data"`)
21+
- Fixed typo "assiated" → "associated" in `cli_tools.py`
22+
- Re-exported `uniqify` function that was accidentally dropped during explicit-exports migration
1623

1724
### Removed
1825
- Deprecated `asciify_dict()` function (was a Python 2 no-op)

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ classifiers = [
1818
"Programming Language :: Python :: 3.11",
1919
"Programming Language :: Python :: 3.12",
2020
"Programming Language :: Python :: 3.13",
21+
"Programming Language :: Python :: 3.14",
2122
"Topic :: Scientific/Engineering :: Bio-Informatics",
2223
]
2324
dependencies = []
@@ -41,4 +42,7 @@ line-length = 100
4142

4243
[tool.ruff.lint]
4344
select = ["E", "F", "I", "W"]
44-
ignore = ["E501", "F403", "F405"]
45+
ignore = ["E501"]
46+
47+
[tool.ruff.lint.per-file-ignores]
48+
"tests/*" = ["F403", "F405"]

tests/test_packaging.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
("is_collection_like", isfunction),
2121
("merge_dicts", isfunction),
2222
("powerset", isfunction),
23+
("uniqify", isfunction),
2324
# environment
2425
("TmpEnv", isclass),
2526
# file_locking

ubiquerg/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
convert_value,
1212
query_yes_no,
1313
)
14-
from .collection import deep_update, is_collection_like, merge_dicts, powerset
14+
from .collection import deep_update, is_collection_like, merge_dicts, powerset, uniqify
1515
from .environment import TmpEnv
1616
from .file_locking import (
1717
READ,
@@ -70,6 +70,7 @@
7070
"size",
7171
"ThreeLocker",
7272
"TmpEnv",
73+
"uniqify",
7374
"untar",
7475
"VersionInHelpParser",
7576
"wait_for_lock",

ubiquerg/cli_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def subparsers(self) -> _SubParsersAction:
4646
return subs[0]
4747

4848
def top_level_args(self) -> list[Any]:
49-
"""Get actions not assiated with any subparser.
49+
"""Get actions not associated with any subparser.
5050
5151
Help and version are also excluded.
5252

ubiquerg/file_locking.py

Lines changed: 2 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import errno
21
import glob
32
import logging
43
import os
54
from contextlib import contextmanager
65
from signal import SIGINT, SIGTERM, signal
76

8-
from .files import create_file_racefree, wait_for_lock
7+
from .files import _create_lock, create_file_racefree, wait_for_lock
8+
from .paths import mkabs
99

1010
PID = os.getpid()
1111
READ = f"read-{PID}"
@@ -290,32 +290,6 @@ def ensure_write_access(lock_path, strict_ro_locks=False):
290290
return True
291291

292292

293-
def _create_lock(lock_path, filepath, wait_max) -> None:
294-
# _LOGGER.debug(f"Creating lock for {filepath} at {lock_path}")
295-
_LOGGER.debug(f"Creating lock at {os.path.basename(lock_path)}")
296-
try:
297-
create_file_racefree(lock_path)
298-
except FileNotFoundError:
299-
parent_dir = os.path.dirname(filepath)
300-
os.makedirs(parent_dir)
301-
_create_lock(lock_path, filepath, wait_max)
302-
except Exception as e:
303-
if e.errno == errno.EEXIST:
304-
# Rare case: file already exists;
305-
# the lock has been created in the split second since the
306-
# last lock existence check,
307-
# wait for the lock file to be gone, but no longer than
308-
# `wait_max`.
309-
_LOGGER.info(
310-
"The lock has been created in the split second since the "
311-
"last lock existence check. Waiting"
312-
)
313-
wait_for_lock(lock_path, wait_max)
314-
_create_lock(lock_path, filepath, wait_max)
315-
else:
316-
raise e
317-
318-
319293
def _remove_lock(lock_path) -> bool:
320294
"""Remove lock.
321295
@@ -345,32 +319,6 @@ def make_all_lock_paths(filepath):
345319
return lock_paths
346320

347321

348-
def mkabs(path, reldir=None):
349-
"""Make sure a path is absolute.
350-
351-
If not already absolute, it's made absolute relative to a given directory.
352-
Also expands ~ and environment variables for kicks.
353-
354-
Args:
355-
path: Path to make absolute
356-
reldir: Relative directory to make path absolute from if it's not already absolute
357-
358-
Returns:
359-
str: Absolute path
360-
"""
361-
362-
def xpand(path):
363-
return os.path.expandvars(os.path.expanduser(path))
364-
365-
if os.path.isabs(xpand(path)):
366-
return xpand(path)
367-
368-
if not reldir:
369-
return os.path.abspath(xpand(path))
370-
371-
return os.path.join(xpand(reldir), xpand(path))
372-
373-
374322
# class OneLocker(object):
375323
# def lock(self, type=READ):
376324
# if not self.filepath:

ubiquerg/files.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,10 @@ def untar(src: str, dst: str) -> None:
111111
dst: path to output folder
112112
"""
113113
with topen(src) as tf:
114-
tf.extractall(path=dst)
114+
if sys.version_info >= (3, 12):
115+
tf.extractall(path=dst, filter="data")
116+
else:
117+
tf.extractall(path=dst)
115118

116119

117120
def get_file_mod_time(pth: str) -> float:

0 commit comments

Comments
 (0)