question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Existing linters, type-checker configuration or other tooling to identify unused Results?

See original GitHub issue

I’m rather fond of the promise of this library in my type-annotated codebase. I already type-check it with Pyright. However, it seems easy to accidentally miss a returned Result if the method otherwise returns None. i.e., if I care about the value in case of success, I’ll surely get a type error in the case that I fail to check for error variants; if I don’t, then I might not be warned about the Result being there at all.

This seems like it would be a common problem for projects using this crate. Is there a well-understood solution already? Perhaps other type-checkers can catch unused return values (like Rust does with #[must_use]), or linters/linter plugins which would provide such functionality. I see issues considering adding this to mypy but they remain open and unimplemented.

What do others do? Is the best solution solution to only use Result when I have a value to return in the success case?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
franciumcommented, Jul 30, 2021

We’d welcome your feedback and experience if you end up playing around with that. Let us know so we can possibly update the README here for overall better user experience with this library.

0reactions
WasabiFancommented, Jul 30, 2021

That’s exactly what I was looking for; evidently, my Ctrl+F attempt was very poorly executed! I saw the mypy thread but missed the reference to Pyright, and I guess didn’t use the right terms in their actual docs. It works great.

Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Linters | golangci-lint
Name Description Presets Since asasalint ⚙️ check for pass any as any in variadic func(...any) bugs 1.47.0 bidichk ⚙️ Checks for dangerous unicode character sequences...
Read more >
Linting · Issue #20 · rome/tools · GitHub
A linter is broadly just a tool that finds potential problems in your code. A type checker is also another form of a...
Read more >
A Complete Guide to Linting Go Programs - freshman.tech
This article demonstrates a comprehensive linting setup for Go projects, and discusses the best way to introduce it into an existing ...
Read more >
Linters aren't in your way. They're on your side
Traditionally, linters make sure your code is clean and easy for teammates to read. They check for errors, bugs, style, and more.
Read more >
golangci-lint - want to "really" ignore a go file not simply ...
The following approaches "functionally" work but gave us poor performance ... //nolint; skip-dirs or skip-files settings; // Code generated by ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found