python-anyconfig icon indicating copy to clipboard operation
python-anyconfig copied to clipboard

DeprecationWarning when running with pytest

Open SimonDR-Boltzmann opened this issue 3 months ago • 3 comments

Describe the bug When running a file that does anyconfig.load with pytest, a DeprecationWarning is thrown:

venv/lib/python3.11/site-packages/anyconfig/processors/utils.py:245: DeprecationWarning: SelectableGroups dict interface is deprecated. Use select.
    for res in (eps.get(pgroup, []) if isinstance(eps, dict)

To Reproduce Steps to reproduce the behavior:

  1. create test.yml with content "test: 123"
  2. create test.py with content
import anyconfig

def test_load():
    anyconfig.load("test.yml")
  1. Run the file with pytest test.py

Expected behavior No warnings

Desktop (please complete the following information):

  • Version 0.14.0

Additional context The deprecation warning seems to come from importlib_metadata, see: https://github.com/python/importlib_metadata/issues/298

SimonDR-Boltzmann avatar Sep 11 '25 09:09 SimonDR-Boltzmann

@SimonDR-Boltzmann Thanks for your report!

Currently, anyconfig supports python 3.9 and importlib.metadata for python 3.9 does not seem to support that 'select' interface yet. So I cannot remove the code causing that warning until I drop its python 3.9 support.

python-anyconfig.git on  next [$?] via 🐍 v3.9.23 (py39)
✦ ❯ ./.tox/py39/bin/python3.9
Python 3.9.23 (main, Jun  4 2025, 00:00:00)
[GCC 15.1.1 20250521 (Red Hat 15.1.1-2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import importlib.metadata; eps = importlib.metadata.entry_points()
>>> eps.select
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'dict' object has no attribute 'select'
>>> isinstance(eps, dict)
True
>>>

ssato avatar Sep 11 '25 16:09 ssato

Ah, I see. That makes sense, thank you for the explanation. Feel free to close this issue again then (unless you feel suppressing the warning until 3.9 is dropped would be worthwhile).

SimonDR-Boltzmann avatar Sep 12 '25 07:09 SimonDR-Boltzmann

I'll keep this to remember working on this later.

Anyway, thanks a lot for your report!

ssato avatar Sep 12 '25 11:09 ssato