Skip to content

Fix get_capability typing overloads#595

Merged
alcarney merged 5 commits intoopenlawlibrary:mainfrom
alcarney:push-myrwmwzuozyo
Mar 8, 2026
Merged

Fix get_capability typing overloads#595
alcarney merged 5 commits intoopenlawlibrary:mainfrom
alcarney:push-myrwmwzuozyo

Conversation

@alcarney
Copy link
Collaborator

@alcarney alcarney commented Mar 4, 2026

Description (e.g. "Related to ...", etc.)

By trying to fix #592 I realised that the typing overrides we generate for get_capability don't make much sense.

  • First there was the issue where Sequence[str] was reported as str.

  • However, the script also tried to unpack types like Union[DefinitionOptions, bool]

    I'd appreciate a second opinion, but I don't think this is correct?

    Since the types in the union have different "shapes" you can't guarantee that definition_provider.work_done_progress exists so wouldn't the safer option be to stop at definition_provider to encourage the caller to handle each type separately?

    Assuming the answer to this is "yes", I've tweaked the script to only unpack Optional[T] capabilities

As a result, many overloads have been deleted.

This PR also tidies up the generate_code.py script and migrates away from deprecated typing syntax

Closes #592

Code review checklist (for code reviewer to complete)

  • Pull request represents a single change (i.e. not fixing disparate/unrelated things in a single PR)
  • Title summarizes what is changing
  • Commit messages are meaningful (see this for details)
  • Tests have been included and/or updated, as appropriate
  • Docstrings have been included and/or updated, as appropriate
  • Standalone docs have been updated accordingly

Automated linters

You can run the lints that are run on CI locally with:

uv run --all-extras poe lint

@tombh tombh mentioned this pull request Mar 7, 2026
6 tasks
@alcarney alcarney force-pushed the push-myrwmwzuozyo branch from 44afbe3 to c54eb0e Compare March 8, 2026 11:44
@alcarney alcarney merged commit 42f5fa3 into openlawlibrary:main Mar 8, 2026
18 checks passed
@alcarney
Copy link
Collaborator Author

alcarney commented Mar 8, 2026

Thanks! :)

@alcarney alcarney deleted the push-myrwmwzuozyo branch March 8, 2026 11:54
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.

Some capabilities are incorrectly singular

2 participants