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 stubs: Exception types must inherit from (Base)Exception #1020

Closed
intgr opened this issue May 10, 2023 · 0 comments
Closed

Type stubs: Exception types must inherit from (Base)Exception #1020

intgr opened this issue May 10, 2023 · 0 comments
Assignees
Labels

Comments

@intgr
Copy link

intgr commented May 10, 2023

Describe the bug

There are type stubs for some exception calsses, such as vmodl.MethodFault. These should derive from Python's Exception or BaseException classes.

Without that, using the class in an except clause causes mypy errors. For example https://github.com/vmware/pyvmomi-community-samples/blob/master/samples/waitforupdates.py#LL109C36-L109C36

    try:
        pc_filter = prop_collector.CreateFilter(filter_spec, True)
        atexit.register(pc_filter.Destroy)
        return pc_filter
    except vmodl.MethodFault as ex:
        #  ^^^^^^^^^^^^^^^^^

Mypy complains:

waitforupdates.py:227:12: error: Exception type must be derived from BaseException  [misc]

Reproduction steps

  1. Manually fixed syntax errors reported in Syntax error in vim/__init__pyi #1015
  2. Installed resulting package with pip
  3. Ran mypy over my codebase

Expected behavior

Handling exceptions should not cause typechecker errors.

Additional context

No response

@intgr intgr added the bug label May 10, 2023
@DanielDraganov DanielDraganov self-assigned this May 22, 2023
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

2 participants