Skip to content

fix typings by resolving exports#1731

Merged
RobinPicard merged 4 commits intodottxt-ai:mainfrom
the-vampiire:fix/typings
Aug 23, 2025
Merged

fix typings by resolving exports#1731
RobinPicard merged 4 commits intodottxt-ai:mainfrom
the-vampiire:fix/typings

Conversation

@the-vampiire
Copy link
Contributor

fix typing structure for better type checking and ide support

this pr improves the typing structure across the outlines library by adding explicit __all__ declarations to packages and converting root imports to proper re-exports.

closes #1730

changes made

added __all__ lists to all packages

  • outlines/backends/ - exports backend classes, constants, and public functions
  • outlines/models/ - exports all model classes, factory functions, and type unions
  • outlines/types/ - exports dsl functions, regex types, and submodules (cleaned up third-party re-exports)
  • outlines/types/locale/ - exports locale submodules
  • outlines/processors/ - exports processor classes
  • outlines/processors/tensor_adapters/ - exports tensor adapter classes

fixed root outlines/__init__.py

  • removed the __all__ list entirely (including undefined prompt reference)
  • converted module imports to explicit re-exports using import x as x pattern:
    • import outlines.grammarsfrom outlines import grammars as grammars
    • import outlines.inputsfrom outlines import inputs as inputs
    • import outlines.processorsfrom outlines import processors as processors
    • import outlines.typesfrom outlines import types as types
  • kept existing from imports and wildcard models import unchanged

cleaned up inappropriate re-exports

  • removed third-party library exports from outlines/types/__init__.py (pydantic, jsonschema, etc.)
  • placed __all__ declarations after imports following pep 8 conventions

testing results

passed

  • core tests: 194/194 tests passed for types, templates, and generator functionality
  • linting: ruff checks pass with zero issues
  • formatting: all modified files properly formatted
  • pre-commit hooks: all checks pass
    • check for merge conflicts
    • debug statements check
    • file endings
    • trailing whitespace
    • mypy
    • ruff
uv run pre-commit run --all-files
   Built outlines @ file:///Users/vamp/magic/forks/outlines
Uninstalled 1 package in 0.66ms
Installed 1 package in 0.89ms
check for merge conflicts................................................Passed
debug statements (python)................................................Passed
fix end of files.........................................................Passed
trim trailing whitespace.................................................Passed
mypy.....................................................................Passed
ruff.....................................................................Passed
  • import functionality: confirmed backward compatibility maintained

skipped/expected failures

  • llamacpp tests: skipped due to version incompatibility with llama_model_get_vocab (unrelated to typing changes)
  • llguidance tests: skipped due to dependency issues (unrelated to typing changes)
  • mypy on full codebase: 44 errors in existing code (mostly dependency version issues, not from our changes)

benefits

  • better type checking support in ides
  • explicit control over public api surface
  • improved autocomplete functionality
  • cleaner package organization
  • maintains full backward compatibility

the typing structure now properly declares what each package exports, making it easier for type checkers and ides to understand the public api while keeping all existing functionality intact.

@the-vampiire
Copy link
Contributor Author

i set outlines.models as well as preserving the top-level outlines.*:

image image

all typings finally working!

Copy link
Contributor

@RobinPicard RobinPicard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot! There's just the issue in the workflow with building the documentation to fix before merging.

@the-vampiire
Copy link
Contributor Author

Thanks a lot! There's just the issue in the workflow with building the documentation to fix before merging.

got it fixed. FYI that the change does now make the API reference go from

before

image

now (since these are all top-level on outlines)

image

@RobinPicard
Copy link
Contributor

Unrelated to this PR: is there somewhere we could discuss about the Langextract plugin @the-vampiire? I'm fine with LinkedIn, Telegram, Discord... up to you

@the-vampiire
Copy link
Contributor Author

i think its ready now. @RobinPicard ya that would be great. i'm on the .txt discord. what is your username i will send you a dm

@RobinPicard
Copy link
Contributor

Awesome! My username is vrepo54

@RobinPicard RobinPicard merged commit bebca54 into dottxt-ai:main Aug 23, 2025
6 checks passed
@the-vampiire
Copy link
Contributor Author

nice glad i don't have to install my fork anymore lol. i dmd you on discord

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.

vscode/pylance intellisense broken for most exported symbols

2 participants