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

[QUESTION] How to suppress type check warnings? #165

Open
XSven opened this issue Jan 24, 2025 · 0 comments
Open

[QUESTION] How to suppress type check warnings? #165

XSven opened this issue Jan 24, 2025 · 0 comments

Comments

@XSven
Copy link

XSven commented Jan 24, 2025

This is my use case

use strict;
use warnings;

use Test::More import => [ qw( is ) ], tests => 3;
use Test::Warn qw( warning_like );

use Type::Params      qw( signature );
use Types::Path::Tiny qw( File  );
use Types::Standard   qw( Str );

my $signature = signature( multiple => [ { positional => [ File ], }, { positional => [ Str ] } ] );

$signature->( __FILE__ );
is ${^_TYPE_PARAMS_MULTISIG}, 0, "is 'File'";

# https://perldoc.perl.org/perldiag#Unsuccessful-%25s-on-filename-containing-newline
warning_like { $signature->( "foo\n" ) } qr/\AUnsuccessful stat on filename containing newline/,
  "stat() call raises diagnostic message as warning ('newline' category)";
is ${^_TYPE_PARAMS_MULTISIG}, 1, "is 'Str'";

The mutisig signature call raises a warning because I have passed the string "foo\n" that the File check gets applied to. I know that the Types::Path::Tiny types library isn't maintained by you but type checks in general could raise harmless warnings and I am asking for a configuration way to suppress them. I don't want to suppress all warnings but only warnings of certain categories?

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

No branches or pull requests

1 participant