Skip to content

Conversation

@cclauss
Copy link

@cclauss cclauss commented Nov 28, 2025

An undefined name is likely to raise NameError at runtime.

% ruff check --output-format=concise --select=F821 docs/source/_ext/entities.py

docs/source/_ext/entities.py:87:70: F821 Undefined name `name_node`
docs/source/_ext/entities.py:160:39: F821 Undefined name `NoUri`
docs/source/_ext/entities.py:164:28: F821 Undefined name `NoUri`

NoUri: https://www.sphinx-doc.org/en/master/_modules/sphinx/errors.html

% ruff rule F821

undefined-name (F821)

Derived from the Pyflakes linter.

What it does

Checks for uses of undefined names.

Why is this bad?

An undefined name is likely to raise NameError at runtime.

Example

def double():
    return n * 2  # raises `NameError` if `n` is undefined when `double` is called

Use instead:

def double(n):
    return n * 2

Options

  • [target-version]: Can be used to configure which symbols Ruff will understand
    as being available in the builtins namespace.

References

Undefined names in Python code can raise `NameError` at runtime.

% `ruff check --output-format=concise --select=F821 docs/source/_ext/entities.py`
```
docs/source/_ext/entities.py:87:70: F821 Undefined name `name_node`
docs/source/_ext/entities.py:160:39: F821 Undefined name `NoUri`
docs/source/_ext/entities.py:164:28: F821 Undefined name `NoUri`
```
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants