Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: DefinedNamespace: fixed handling of control attributes. #1825

Commits on Apr 18, 2022

  1. fix: DefinedNamespace: fixed handling of control attributes.

    This patch changes `DefinedNamespace` to always raise `AttributeError` for
    the name `_NS` and other "control attributes" from `__getattr__`, and to
    also not consider them as part of the `__dir__`.
    
    Without doign this `inspect.signature` recurses
    infinitely when inspecting `rdflib.namespace.DefinedNamespace` and `dir`
    results in an `AttributeError`.
    
    One situation in which this occurs is when sphinx autodoc is generating
    documentation from type hints:
    
    ```
    WARNING: error while formatting signature for rdflib.namespace.DefinedNamespace: Handler <function record_typehints at 0x7fbf2696dd40> for event 'autodoc-process-signature' threw an exception (exception: maximum recursion depth exceeded while calling a Python object)
    ```
    
    Also:
    - Changed `DefinedNamespace.__repr__` to use repr for formatting
      the URI string instead of quoting by hand. This probably has no real effect,
      as the namespace shoudl not have a double or single quote in it, but
      it is still correct to use repr.
    
    The main reason for this patch is to eliminate a warning for sphinx
    which is blocking the build since `sphinx.fail_on_warning` was enabled.
    
    There is also two cases in `DefinedNamespaceMeta` where an undefined
    method is being called, these were causing type errors before, but I
    added notes now to indicate they are real bugs, because if they are
    reached they just result in `AttributeError` exceptions. This should be
    fixed sometime, not sure what the reasoning behind it was.
    aucampia committed Apr 18, 2022
    Configuration menu
    Copy the full SHA
    fdc6479 View commit details
    Browse the repository at this point in the history