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

Type annotation parsing warning for Pydantic BaseModel private attributes #792

Open
DawnEver opened this issue Mar 27, 2025 · 0 comments
Open
Labels

Comments

@DawnEver
Copy link

Problem Description

When using pdoc to generate documentation for Pydantic BaseModel classes, warnings appear about parsing type annotations for __pydantic_private__ and __pydantic_extra__ attributes. The warning indicates that a 'function' object is not subscriptable when trying to parse the type annotations dict[str, Any] | None.

This occurs even with simple Pydantic model definitions and affects the documentation generation process.

Steps to reproduce the behavior:

  1. Install pdoc and pydantic
  2. Create a Python file with the following content:
from pydantic import BaseModel

class Foo(BaseModel):
    """Test model"""
    bar: int

class Bar(BaseModel):
    """Another test model"""
    foo: Foo
  1. Run pdoc foobar.py, warning appears:
Warn: Error parsing type annotation dict[str, Any] | None for pydantic.main.BaseModel.__pydantic_private__: 'function' object is 
not subscriptable(.../lib/python3.13/site-packages/pdoc/doc_types.py:123)
Warn: Error parsing type annotation dict[str, Any] | None for pydantic.main.BaseModel.__pydantic_extra__: 'function' object is not subscriptable(.../lib/python3.13/site-packages/pdoc/doc_types.py:123)

System Information

pdoc: 15.0.1
Python: 3.13.2
Platform: macOS-10.16-x86_64-i386-64bit-Mach-O
pydantic: 2.10.6

@DawnEver DawnEver added the bug label Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant