Skip to content

Commit

Permalink
improve summary (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
quintenroets authored Oct 20, 2024
1 parent cab2293 commit 22c41c4
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 2.0.8
current_version = 2.0.9
commit = False
allow_dirty = True

Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
repos:
- repo: https://github.com/PyCQA/docformatter
rev: v1.7.5
rev: eb1df34
hooks:
- id: docformatter
args: [--in-place, --make-summary-multi-line, --close-quotes-on-newline, --wrap-summaries, "88"]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.3
rev: v0.7.0
hooks:
- id: ruff
- id: ruff-format
- repo: https://github.com/psf/black
rev: 24.8.0
rev: 24.10.0
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
Expand Down
25 changes: 18 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,19 @@

Maximize your productivity with minimal code!

Superpathlib is an enhanced pathlib library offering advanced file operations that are intuitive and easy to use.
The package extends Python's standard library [pathlib](https://docs.python.org/3/library/pathlib.html) module and offers new features without compromising performance.
The Path class supports subclassing, which has been added to the standard library for [python3.12+](https://docs.python.org/3/whatsnew/3.12.html).
Superpathlib is an enhanced version of Python's standard [pathlib](https://docs.python.org/3/library/pathlib.html), designed to make file operations more intuitive and extend functionality without compromising performance. It builds on pathlib by introducing additional properties, methods, and shortcuts that simplify common file manipulations and reduce boilerplate code.

For custom operations, the package supports subclassing, which has been added to the standard library in [python3.12](https://docs.python.org/3/whatsnew/3.12.html).

## Key features:
* Read and write content in various formats such as text, bytes, YAML, JSON, and even NumPy arrays
* Access and modify file metadata like file size, modification time, and custom tags
* Utility methods:
* `rmtree` to remove directories recursively
* `copy_to` to copy content
* `tempfile` to create and use temporary files
* `find` for recursive search
* `unpack` for unpacking archives

## Usage

Expand Down Expand Up @@ -106,8 +116,7 @@ class Path(superpathlib.Path):
return sum(1 for _ in self.iterdir())
```
This only works if you inherit from superpathlib Path, not pathlib Path
The standard pathlib library supports this for Python versions starting from [python3.12](https://docs.python.org/3/whatsnew/3.12.html).
## Installation
Expand All @@ -118,7 +127,9 @@ or
```shell
pip install superpathlib[full]
```
to include additional dependencies like PyYAML for handling YAML files
or
Install the packages corresponding with the properties you want to use:
* e.g. PyYaml for yaml property
Manually install the packages corresponding with the features you want to use:
* Packages listed in pyproject.toml
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "superpathlib"
version = "2.0.8"
version = "2.0.9"
description = "Extended Pathlib"
authors = [{name = "Quinten Roets", email = "qdr2104@columbia.edu"}]
license = {text = "MIT"}
Expand Down
4 changes: 2 additions & 2 deletions src/superpathlib/override.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import typing
from collections.abc import Callable, Generator
from functools import wraps
from pathlib import PurePath
from os import PathLike
from typing import IO, Any, TypeVar

from . import encryption
Expand Down Expand Up @@ -80,7 +80,7 @@ def rename(self: T, target: str | T, *, exist_ok: bool = False) -> T:
raise
return target_path

def replace(self: T, target: str | PurePath) -> T:
def replace(self: T, target: str | PathLike[str]) -> T:
path = self.rename(target, exist_ok=True)
return typing.cast(T, path)

Expand Down
4 changes: 2 additions & 2 deletions tests/test_cached_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from package_utils.storage import CachedFileContent

from superpathlib import Path
from tests.content import byte_content, text_content
from tests.content import byte_content, slower_test_settings, text_content
from tests.utils import ignore_fixture_warning


Expand Down Expand Up @@ -39,7 +39,7 @@ class Storage:
verify_storage(Storage, content)


@ignore_fixture_warning
@slower_test_settings
@text_content
def test_created_content(path: Path, content: dict[str, dict[str, str]]) -> None:
class Storage:
Expand Down
7 changes: 4 additions & 3 deletions tests/test_functionality.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def test_copy(path: Path, path2: Path, content: bytes) -> None:
assert path2.byte_content == content


@ignore_fixture_warning
@slower_test_settings
@byte_content
def test_copy_if_newer_copies(path: Path, path2: Path, content: bytes) -> None:
path.byte_content = content
Expand All @@ -74,7 +74,7 @@ def test_copy_if_newer_copies(path: Path, path2: Path, content: bytes) -> None:
assert path2.byte_content == content


@ignore_fixture_warning
@slower_test_settings
@byte_content
def test_copy_if_newer_skips(path: Path, path2: Path, content: bytes) -> None:
path.byte_content = content
Expand All @@ -83,7 +83,7 @@ def test_copy_if_newer_skips(path: Path, path2: Path, content: bytes) -> None:
assert path2.byte_content == b""


@ignore_fixture_warning
@slower_test_settings
@byte_content
def test_move(path: Path, path2: Path, content: bytes) -> None:
path.byte_content = content
Expand Down Expand Up @@ -269,6 +269,7 @@ def test_rmtree_preserve_root(directory: Path) -> None:
directory.rmtree(remove_root=False)


@slower_test_settings
@dictionary_content
def test_yaml_update(content: dict[str, str]) -> None:
with Path.tempfile() as path:
Expand Down

0 comments on commit 22c41c4

Please sign in to comment.