Skip to content

Python fails on get_type_hints(URIRef) #3187

@ticapix

Description

@ticapix

Hello,

Using rdflib-7.1.4 and python 3.13.6, I'm getting an error with this code:

from typing import get_type_hints

import rdflib
from rdflib import URIRef
from rdflib.paths import Path

print(rdflib.__version__)
print("Path", get_type_hints(Path))  # <- works
print("URIRef", get_type_hints(URIRef))  # <- fails
7.1.4
Path {'__or__': typing.Callable[[rdflib.paths.Path, typing.Union[rdflib.term.URIRef, rdflib.paths.Path]], rdflib.paths.AlternativePath], '__invert__': typing.Callable[[rdflib.paths.Path], rdflib.paths.InvPath], '__neg__': typing.Callable[[rdflib.paths.Path], rdflib.paths.NegatedPath], '__truediv__': typing.Callable[[rdflib.paths.Path, typing.Union[rdflib.term.URIRef, rdflib.paths.Path]], rdflib.paths.SequencePath], '__mul__': typing.Callable[[rdflib.paths.Path, str], rdflib.paths.MulPath]}
Traceback (most recent call last):
  File "test.py", line 38, in <module>
    print("URIRef", get_type_hints(URIRef))
                    ~~~~~~~~~~~~~~^^^^^^^^
  File "/home/linuxbrew/.linuxbrew/opt/python@3.13/lib/python3.13/typing.py", line 2461, in get_type_hints
    value = _eval_type(value, base_globals, base_locals, base.__type_params__)
  File "/home/linuxbrew/.linuxbrew/opt/python@3.13/lib/python3.13/typing.py", line 474, in _eval_type
    return t._evaluate(globalns, localns, type_params, recursive_guard=recursive_guard)
           ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/linuxbrew/.linuxbrew/opt/python@3.13/lib/python3.13/typing.py", line 1081, in _evaluate
    eval(self.__forward_code__, globalns, localns),
    ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<string>", line 1, in <module>
NameError: name 'Path' is not defined. Did you mean: 'math'?

Any clue why ?

thank you,
Pierre

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions