Commit graph

12521 commits

Author SHA1 Message Date
snejus
d487d675b9 Increment version to 2.3.1 2025-05-14 09:53:19 +00:00
Šarūnas Nejus
69a76edc33
Pin poetry version below <2 (#5782)
Force `poetry` version below 2 to avoid it mangling file modification
times in `sdist`.

Fixes #5770
2025-05-14 10:48:00 +01:00
Šarūnas Nejus
80cf9ea888
Update pipx-install-action action version 2025-05-14 10:42:07 +01:00
Šarūnas Nejus
28781e9077
Pin Poetry version <2 2025-05-14 10:42:07 +01:00
Gavin Tronset
b92a1b3d98
Add beets-filetote to community plugins docs (#5779)
Add link to community plugin
[`beets-filetote`](https://github.com/gtronset/beets-filetote).

This plugin is the spiritual successor to
[beets-copyartifacts](https://github.com/adammillerio/beets-copyartifacts)
(`beets-copyartifacts3` was last updated 3 years ago) and
[beets-extrafiles](https://github.com/Holzhaus/beets-extrafiles) (last
updated 5 years ago).

Given the updates and changes in beets and how outdated those plugins
are, does it make sense to keep `beets-copyartifacts` in the community
plugins list?

---------

Co-authored-by: Sebastian Mohr <39738318+semohr@users.noreply.github.com>
2025-05-13 18:48:43 +02:00
Benedikt
589bd6d599
Art resizer typings v2 (#5734)
A rebased & amended version of
https://github.com/beetbox/beets/pull/4649.

I left a FIXME note regarding a cleanup that I feel should be done at
some point, but that is out-of-scope here when just adding initial
typings.
2025-05-13 12:18:53 +02:00
wisp3rwind
26008eb922 add example for LazySharedInstance 2025-05-13 12:13:40 +02:00
wisp3rwind
aa49385d27 artresizer: address review 2025-05-13 12:13:40 +02:00
wisp3rwind
720023c76f artresizer: adjust code & typings to satisfy mypy
Notably, this replaces the `Shareable` metaclass by a different implementation
of a descriptor: We don't really need to modify class creation here,
because the singleton is only available via the `shared` method, not via
the constructor. Additionally, it appears that mypy can understand the
new code.
2025-05-13 12:13:40 +02:00
wisp3rwind
b18e6e0654 artresizer: revise typings
This is more of a "what should the types be", in particular regarding
paths, it has not yet been run through mypy. That will be done next,
which is probably going to highlight a bunch of issues that should lead
to either the code being fixed, or the types adjusted.
2025-05-13 12:13:40 +02:00
Serene-Arc
c90ff27315 artresizer: make import conditional 2025-05-13 12:13:40 +02:00
Serene-Arc
7acfe8932a artresizer: add some missing typings 2025-05-13 12:13:40 +02:00
Serene-Arc
996a116a62 artresizer: type module 2025-05-13 12:13:40 +02:00
Šarūnas Nejus
0379f68aea
Do not remove everything that follows a dot in item destination path (#5774)
This PR addresses an issue where path legalization, specifically the
`truncate_path` function, incorrectly removed parts of filenames that
followed a dot. This occurred because `pathlib.Path.with_suffix` was
used, which replaces the existing suffix (or what it considers a suffix)
rather than just appending.

The fix modifies `truncate_path` to manually append the original suffix
after truncating the filename stem. This ensures that dots within the
filename, not part of the actual extension, are preserved.

Fixes #5771.
2025-05-12 09:21:10 +01:00
Šarūnas Nejus
a4dabb66cf
Fix extension arg type in the legalize path call
Also tighten `filetype` attribute type - empty value was previously
handled to accommodate a couple of tests, but they aren't failing
anymore, it seems.
2025-05-12 09:14:24 +01:00
Šarūnas Nejus
de09c3217a
Do not 'legalize' paths by removing everything following a dot
TIL that `with_suffix` does not simply append the suffix to the filename
- it instead replaces the old/current suffix. Or whatever seems to
look like a suffix, in our case, unfortunately...
2025-05-12 09:14:24 +01:00
jwynn6
677204238c
Update pathformat.rst (#5754)
Added explainer about escaping closing braces `$}`
2025-05-11 00:55:55 +00:00
snejus
250b0da900 Increment version to 2.3.0 2025-05-07 22:34:25 +00:00
Šarūnas Nejus
2697995428
Update dependencies and address security issues (#5765)
This PR addresses Dependabot vulnerability alerts and secret scanner
reports by updating dependencies and redacting some of the sensitive
configuration field.

* **Dependency Updates:** Updated various dependencies, including those
flagged by Dependabot, as reflected in `poetry.lock`. This resolves
known vulnerabilities.
* **Secret Redaction:** Addressed secret scanner findings by redacting
sensitive configuration values (e.g., `tokenfile`, `apikey`, `password`,
`username`, `userid`) in `beatport`, `discogs`, `embyupdate`,
`fetchart`, `lastimport`, `spotify`, and `subsonicupdate` plugins.
* **Python Version:** Standardized on Python 3.9 across GitHub Actions
workflows.
* **Code Style:** Minor adjustments for `ruff` compatibility, including
string concatenations and f-string quote consistency.
2025-05-07 20:44:45 +01:00
Šarūnas Nejus
a735e747f8
Skip tekstowo lyrics test 2025-05-07 20:39:33 +01:00
Šarūnas Nejus
fdc1aba603
Replace typing.cast with explicit type definitions and ignore TC006 2025-05-07 20:39:33 +01:00
Šarūnas Nejus
99dc0861c2
Redact sensitive fields
Redacted fields reported by GitHub secrets scanner[1] and a couple of others.

1: https://github.com/beetbox/beets/security/secret-scanning?query=is%3Aclosed
2025-05-07 20:39:32 +01:00
Šarūnas Nejus
6869afd7fe
Exclude formatting commit from blame 2025-05-07 10:42:06 +01:00
Šarūnas Nejus
c490ac5810
Fix formatting 2025-05-07 10:41:01 +01:00
Šarūnas Nejus
36d42c5b6f
Ensure that pre-commit ruff version is in sync with dependencies 2025-05-07 10:24:05 +01:00
Šarūnas Nejus
16a6cb1340
Update dependencies
And thus address the following security vulnerabilities: https://github.com/beetbox/beets/security/dependabot
2025-05-07 10:24:05 +01:00
Šarūnas Nejus
63c23c32ed
Add missed out python versions to package classifiers 2025-05-07 10:24:04 +01:00
Šarūnas Nejus
5128a817be
Update missed out python version in the build 2025-05-07 10:24:04 +01:00
Šarūnas Nejus
a40a3d45e4
Install docs dependencies early 2025-05-07 10:24:02 +01:00
Šarūnas Nejus
e1101b7a38
pipeline: remove old tests, integrate with our test suite (#5729)
These have probably not been run by anyone in ages, better to move the
code to our test suite where it is regularly exercised. In fact, the
latter covers most of the cases already. The only missing tests seem to
be those were exceptions are raised in the first or last stage. Thus,
this adds such tests.
2025-05-06 13:58:09 +01:00
wisp3rwind
2c68349314 pipeline: remove old tests, integrate with out test suite
These have probably not been run by anyone in ages, better to move the
code to our test suite where it is regularly exercised. In fact, the
latter covers most of the cases already. The only missing tests seem to
be those were exceptions are raised in the first or last stage. Thus,
this adds such tests.
2025-05-06 14:51:20 +02:00
Benedikt
9756a5d061
Fix _legalize_path types and clean up path legalisation logic (#5224)
**Refactor: Simplify Path Generation and Legalization**

This PR refactors the way destination paths for library items are
generated and made filesystem-safe. The goal is to simplify the process,
make it more robust, and centralize most of the path manipulation logic.

**Key Changes:**

*   **`Item.destination` Simplified:**
* The method now has a clearer interface, primarily controlled by the
`relative_to_libdir` flag (replacing the old `fragment` flag).
* It consistently returns the path as `bytes`, ready for filesystem
operations.
* Path legalization logic (sanitization, truncation, replacements) is
now delegated to `util.legalize_path`.

*   **`util.legalize_path` Enhanced:**
* Takes responsibility for the full legalization process, including
truncation based on filesystem limits.
* Uses new helper functions (`util.truncate_path`, `util.truncate_str`)
for robust truncation of path components while preserving extensions and
handling multi-byte characters correctly.
* Includes logic to handle potential conflicts where
sanitization/replacements might interfere with truncation, falling back
to default rules if necessary.

*   **Centralized Max Length:**
* A new cached function `util.get_max_filename_length` determines the
maximum filename length, checking the config first and then querying the
filesystem.

This refactoring leads to cleaner code by separating concerns:
`Item.destination` focuses on generating the *intended* path based on
metadata and formats, while `util.legalize_path` and its helpers handle
the complexities of making that path valid for the target filesystem.
2025-05-06 14:49:51 +02:00
Šarūnas Nejus
921b7ed9ea
Rewrite legalisation tests for readability 2025-05-04 12:23:26 +01:00
Šarūnas Nejus
6a7832f207
Adjust tests to work in Windows 2025-05-04 12:23:26 +01:00
Šarūnas Nejus
5826d6b59b
Remove handling of mbcs encoding
This has been phased out in Python 3.6.

https://peps.python.org/pep-0529/
2025-05-04 12:23:26 +01:00
Šarūnas Nejus
4fcb148d60
Add test for legalization logic 2025-05-04 12:23:26 +01:00
Šarūnas Nejus
40fbc8ee7e
Fix and simplify path truncation 2025-05-04 12:23:26 +01:00
Šarūnas Nejus
b3fd84b356
Move max filename length calculation closer to where it is used 2025-05-04 12:23:25 +01:00
Šarūnas Nejus
d3186859ac
Remove unused platform parameter in item.destination 2025-05-04 12:23:25 +01:00
Šarūnas Nejus
06dd2738bb
Remove never used replacements paramater from item.destination 2025-05-04 12:23:25 +01:00
Šarūnas Nejus
52951bf719
Fix legalize_path types
Background
  The `_legalize_stage` function was causing issues with Mypy due to
  inconsistent type usage between the `path` and `extension` parameters.
  This inconsistency stemmed from the `fragment` parameter influencing the
  types of these variables.

Key issues
  1. `path` was defined as `str`, while `extension` was `bytes`.
  2. Depending on `fragment`, `extension` could be either `str` or `bytes`.
  3. `path` was sometimes converted to `bytes` within `_legalize_stage`.

Item.destination` method
  - The `fragment` parameter determined the output format:
    - `False`: Returned absolute path as bytes (default)
    - `True`: Returned path relative to library directory as str

Thus
  - Rename `fragment` parameter to `relative_to_libdir` for clarity
  - Ensure `Item.destination` returns `bytes` in all cases
  - Code expecting strings now converts the output to `str`
  - Use only `str` type in `_legalize_stage` and `_legalize_path`
    functions
  - These functions are no longer dependent on `relative_to_libdir`
2025-05-04 12:23:22 +01:00
Aidan Epstein
ecdff785f7
Only output verbose details for parentwork plugin when running explicitly (#5135)
Fixes #4120.
2025-05-04 09:34:37 +02:00
Benedikt
5d010e95ec
Use os.fsencode to encode bytes (#5662)
# Remove Python 2 compatibility code for string encoding/decoding

This PR simplifies the codebase by removing Python 2 compatibility code
related to string encoding and decoding operations. Key changes:

- Remove custom `_convert_args`, `arg_encoding()`, `_fsencoding()` and
`convert_command_args()` functions
- Replace with standard library's `os.fsencode()` and `os.fsdecode()`
for file system path handling
- Simplify bytestring/string conversions throughout the codebase
- Update test code to use modern string handling

These changes reduce code complexity and maintenance burden since Python
2 support is no longer needed.
2025-04-22 11:56:53 +02:00
Šarūnas Nejus
9acfa3c175
Remove arg_encoding 2025-04-21 12:41:57 +01:00
Šarūnas Nejus
179ed13e09
Say bye to util._fsencoding 2025-04-21 12:41:57 +01:00
Šarūnas Nejus
980199602e
Encode paths using os.fsencode 2025-04-21 12:41:57 +01:00
Benedikt
43301c4caa
fixup #5701 (#5745)
which added some mypy config to pyproject.toml, leading to mypy ignoring
setup.cfg
 (this shows up in CI output for #5701, but is not very visible
since we currently ignore mypy errors)

Related: https://github.com/beetbox/beets/pull/5728
2025-04-20 10:43:10 +02:00
Šarūnas Nejus
c5bfbde175
Added typehints to the plugins file. (#5701)
Added some typehints to the `plugins.py` file. There are some typehints
missing but I think this is a good first step to get a better DevEx.
2025-04-19 20:20:30 +01:00
Sebastian Mohr
6594bd7f24 Moved all typehint that need a typechecking guard to the top. see
https://github.com/beetbox/beets/pull/5701#discussion_r2051486012
2025-04-19 16:19:07 +02:00
Sebastian Mohr
557cb1a019 minor additions 2025-04-19 13:00:12 +02:00