Skip to content

Conversation

@stanislav-tkach
Copy link
Member

@stanislav-tkach stanislav-tkach commented Dec 11, 2024

Description

This pull request adds allow-panic-in-tests = true to the clippy.toml config.

It is ok to panic in the tests and we already allow the usage of both unwrap and expect (allow-unwrap-in-tests and allow-expect-in-tests). Sometimes it is easier to use a direct panic!() call. For example:

let Address::Stake(address) = cip0134_uri.address() else {
    panic!("Unexpected address type ({uri})");
};

Rewriting this code to use unwrap is possible, but more cumbersome.

Related Pull Requests

I have encountered this issue working on the input-output-hk/catalyst-libs#102 pull request.

Please confirm the following checks

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream module

@stanislav-tkach stanislav-tkach added the review me PR is ready for review label Dec 11, 2024
@stanislav-tkach stanislav-tkach self-assigned this Dec 11, 2024
@stanislav-tkach
Copy link
Member Author

I'm not sure, but it seems that CI failure is unrelated to my changes:

  /h/r/w/c/c/u/earthly-cache-watcher+check *failed* | main.py:67:32: UP006 Use `set` instead of `Set` for type annotation
  /h/r/w/c/c/u/earthly-cache-watcher+check *failed* |    |
  /h/r/w/c/c/u/earthly-cache-watcher+check *failed* | 65 |         self.layer_index: dict[str, int] = {}
  /h/r/w/c/c/u/earthly-cache-watcher+check *failed* | 66 |         self.file_index: dict[str, int] = {}
  /h/r/w/c/c/u/earthly-cache-watcher+check *failed* | 67 |         self.triggered_layers: Set[str] = set()
  /h/r/w/c/c/u/earthly-cache-watcher+check *failed* |    |                                ^^^ UP006

@stanislav-tkach stanislav-tkach force-pushed the clippy-allow-panics-in-tests branch from 2cc464d to 24e9d48 Compare December 12, 2024 10:49
@Mr-Leshiy Mr-Leshiy removed the do not merge yet PR is not ready to be merged yet label Dec 12, 2024
Copy link
Contributor

@Mr-Leshiy Mr-Leshiy left a comment

Choose a reason for hiding this comment

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

LGTM

@stanislav-tkach stanislav-tkach merged commit 7b80392 into master Dec 12, 2024
65 checks passed
@stanislav-tkach stanislav-tkach deleted the clippy-allow-panics-in-tests branch December 12, 2024 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review me PR is ready for review

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants