Bug 2576580 - python-platformdirs fails to build with Python 3.16: DeprecationWarning: 'typing.AnyStr' is deprecated and slated for removal in Python 3.21.
Summary: python-platformdirs fails to build with Python 3.16: DeprecationWarning: 'typ...
Keywords:
Status: NEW
Alias: None
Product: Fedora
Classification: Fedora
Component: python-platformdirs
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Carl George 🤠
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.16
TreeView+ depends on / blocked
 
Reported: 2026-11-19 12:47 UTC by Karolina Surma
Modified: 2026-11-19 12:47 UTC (History)
4 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed:
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Karolina Surma 2026-11-19 12:47:01 UTC
python-platformdirs fails to build with Python 3.16.0a2.

________________ test_import_before_pytest_main[worker-thread] _________________

tmp_path = PosixPath('/tmp/pytest-of-mockbuild/pytest-0/test_import_before_pytest_main1')
invocation = 'executor.submit(pytest.main, args).result()'
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb255fd54e0>

    @pytest.mark.parametrize(
        "invocation",
        [
            pytest.param("pytest.main(args)", id="main-thread"),
            pytest.param("executor.submit(pytest.main, args).result()", id="worker-thread"),
        ],
    )
    def test_import_before_pytest_main(tmp_path: Path, invocation: str, monkeypatch: pytest.MonkeyPatch) -> None:
        monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", raising=False)
        monkeypatch.delenv("PYTEST_ADDOPTS", raising=False)
        (tmp_path / "test_example.py").write_text(
            "from pathlib import Path\n"
            "from platformdirs import PlatformDirs\n\n"
            "def test_isolation(platformdirs_isolated: Path) -> None:\n"
            "    assert PlatformDirs('app').user_config_path == platformdirs_isolated / 'user_config' / 'app'\n",
            encoding="utf-8",
        )
        code: Final = (
            "import platformdirs\n"
            "import pytest\n"
            "from concurrent.futures import ThreadPoolExecutor\n"
            "args = ['-q', '-Werror']\n"
            "with ThreadPoolExecutor(max_workers=1) as executor:\n"
            f"    raise SystemExit({invocation})\n"
        )
>       assert "1 passed" in check_output([sys.executable, "-Werror", "-c", code], cwd=tmp_path, text=True)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/test_pytest_plugin.py:57: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib64/python3.16/subprocess.py:587: in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

input = None, capture_output = False, timeout = None, check = True
popenargs = (['/usr/bin/python3', '-Werror', '-c', "import platformdirs\nimport pytest\nfrom concurrent.futures import ThreadPoolE...ThreadPoolExecutor(max_workers=1) as executor:\n    raise SystemExit(executor.submit(pytest.main, args).result())\n"],)
kwargs = {'stdout': -1, 'cwd': PosixPath('/tmp/pytest-of-mockbuild/pytest-0/test_import_before_pytest_main1'), 'text': True}

    def run(*popenargs,
            input=None, capture_output=False, timeout=None, check=False, **kwargs):
        """Run command with arguments and return a CompletedProcess instance.
    
        The returned instance will have attributes args, returncode, stdout and
        stderr. By default, stdout and stderr are not captured, and those attributes
        will be None. Pass stdout=PIPE and/or stderr=PIPE in order to capture them,
        or pass capture_output=True to capture both.
    
        If check is True and the exit code was non-zero, it raises a
        CalledProcessError. The CalledProcessError object will have the return code
        in the returncode attribute, and output & stderr attributes if those streams
        were captured.
    
        If timeout (seconds) is given and the process takes too long,
         a TimeoutExpired exception will be raised.
    
        There is an optional argument "input", allowing you to
        pass bytes or a string to the subprocess's stdin.  If you use this argument
        you may not also use the Popen constructor's "stdin" argument, as
        it will be used internally.
    
        By default, all communication is in bytes, and therefore any "input" should
        be bytes, and the stdout and stderr will be bytes. If in text mode, any
        "input" should be a string, and stdout and stderr will be strings decoded
        according to locale encoding, or by "encoding" if set. Text mode is
        triggered by setting any of text, encoding, errors or universal_newlines.
    
        The other arguments are the same as for the Popen constructor.
        """
        if input is not None:
            if kwargs.get('stdin') is not None:
                raise ValueError('stdin and input arguments may not both be used.')
            kwargs['stdin'] = PIPE
    
        if capture_output:
            if kwargs.get('stdout') is not None or kwargs.get('stderr') is not None:
                raise ValueError('stdout and stderr arguments may not be used '
                                 'with capture_output.')
            kwargs['stdout'] = PIPE
            kwargs['stderr'] = PIPE
    
        with Popen(*popenargs, **kwargs) as process:
            try:
                stdout, stderr = process.communicate(input, timeout=timeout)
            except TimeoutExpired as exc:
                process.kill()
                if _mswindows:
                    # Windows accumulates the output in a single blocking
                    # read() call run on child threads, with the timeout
                    # being done in a join() on those threads.  communicate()
                    # _after_ kill() is required to collect that and add it
                    # to the exception.
                    exc.stdout, exc.stderr = process.communicate()
                else:
                    # POSIX _communicate already populated the output so
                    # far into the TimeoutExpired exception.
                    process.wait()
                raise
            except:  # Including KeyboardInterrupt, communicate handled that.
                process.kill()
                # We don't call process.wait() as .__exit__ does that for us.
                raise
            retcode = process.poll()
            if check and retcode:
>               raise CalledProcessError(retcode, process.args,
                                         output=stdout, stderr=stderr)
E               subprocess.CalledProcessError: Command ['/usr/bin/python3', '-Werror', '-c', "import platformdirs\nimport pytest\nfrom concurrent.futures import ThreadPoolExecutor\nargs = ['-q', '-Werror']\nwith ThreadPoolExecutor(max_workers=1) as executor:\n    raise SystemExit(executor.submit(pytest.main, args).result())\n"] returned non-zero exit status 1.

/usr/lib64/python3.16/subprocess.py:692: CalledProcessError
----------------------------- Captured stderr call -----------------------------
Traceback (most recent call last):
  File "<string>", line 2, in <module>
    import pytest
  File "/usr/lib/python3.16/site-packages/pytest/__init__.py", line 11, in <module>
    from _pytest.capture import CaptureFixture
  File "/usr/lib/python3.16/site-packages/_pytest/capture.py", line 19, in <module>
    from typing import AnyStr
  File "/usr/lib64/python3.16/typing.py", line 3950, in __getattr__
    warnings._deprecated(
    ~~~~~~~~~~~~~~~~~~~~^
        "typing.AnyStr",
        ^^^^^^^^^^^^^^^^
    ...<5 lines>...
        remove=(3, 21),
        ^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/lib64/python3.16/_py_warnings.py", line 893, in _deprecated
    _wm.warn(msg, DeprecationWarning, stacklevel=stacklevel)
    ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
DeprecationWarning: 'typing.AnyStr' is deprecated and slated for removal in Python 3.21. Use PEP 695 type parameters with constraints instead
https://docs.python.org/3.16/whatsnew/3.16.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.16/fedora-rawhide-x86_64/11359672-python-platformdirs/

For all our attempts to build python-platformdirs with Python 3.16, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.16/package/python-platformdirs/

Testing and mass rebuild of packages is happening in copr.
You can follow these instructions to test locally in mock if your package builds with Python 3.16:
https://copr.fedorainfracloud.org/coprs/g/python/python3.16/

Let us know here if you have any questions.

Python 3.16 is planned to be included in Fedora 47.
To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.16.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires),
so if this package is required a lot, it's important for us to get it fixed soon.

We'd appreciate help from the people who know this package best,
but if you don't want to work on this now, let us know so we can try to work around it on our side.


Note You need to log in before you can comment on or make changes to this bug.