Skip to content

Ignore more exceptions in stubtest #11946

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

Merged
merged 4 commits into from
Jan 12, 2022
Merged

Conversation

JelleZijlstra
Copy link
Member

)
try:
runtime_attr = getattr(runtime, mangled_entry)
except Exception:
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to log it somehow?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure there's a good framework for that. Perhaps we can add a constant similar to MISSING, or fall back to a runtime value of Any if a non-AttriibuteError exception is thrown.

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

This looks good, although it might make it possible for verify to be called with verify(MISSING, MISSING, ...), which gives a not ideal error:

In [4]: print(list(verify(MISSING, MISSING, ["asdf", "fdsa"]))[0].get_description())
error: asdf.fdsa is not present in stub
Stub:
MISSING
Runtime:
MISSING

@JelleZijlstra
Copy link
Member Author

I don't think that would be new from this change, since it already did getattr(..., ..., MISSING).

@hauntsaninja
Copy link
Collaborator

hauntsaninja commented Jan 12, 2022

It is new. The way we source entries, they're guaranteed to exist either in the stub or at runtime. Now if we have something that isn't in the stubs, shows up in vars but raises an error when you getattr it, we'll end up with MISSING, MISSING. It's niche and I thought stubtest would choke, but it looks like it'd just ends up giving a slightly confusing message, which is fine.

Actually, we should not be calling verify if getattr fails with an unexpected Exception. So something like this will avoid confusing errors:

try:
    runtime_attr = getattr(runtime, mangled_entry, MISSING)
except Exception:
    pass
else:
    yield from verify(stub_to_verify, runtime_attr, object_path + [entry])

@JelleZijlstra
Copy link
Member Author

Thanks, I applied that suggestion.

@hauntsaninja
Copy link
Collaborator

Looks like githubstatus.com just acknowledged issues with Github Actions (I ran into issues on another repo as well)

@JelleZijlstra JelleZijlstra merged commit fa16759 into master Jan 12, 2022
@JelleZijlstra JelleZijlstra deleted the JelleZijlstra-patch-1 branch January 12, 2022 04:29
tushar-deepsource pushed a commit to DeepSourceCorp/mypy that referenced this pull request Jan 20, 2022
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.

3 participants