Skip to content

Check Pattern and Match annotations - #576

Open
RavSinghChandan wants to merge 1 commit into
agronholm:masterfrom
RavSinghChandan:check-pattern-and-match-flavour
Open

Check Pattern and Match annotations#576
RavSinghChandan wants to merge 1 commit into
agronholm:masterfrom
RavSinghChandan:check-pattern-and-match-flavour

Conversation

@RavSinghChandan

Copy link
Copy Markdown

Neither has a checker registered, so both fall through to a plain isinstance against the bare type:

check_type(re.compile(b"x"), Pattern[str])   # passes
check_type(re.compile("x"), Pattern[bytes])  # passes
check_type(re.compile("x"), Match[str])      # passes - a pattern, not a match

The argument says which flavour the pattern was compiled from, so it is checked against the pattern itself rather than against anything matched

Neither had a checker registered, so both fell through to a plain isinstance
against the bare type. Pattern[str] accepted a pattern compiled from bytes,
Pattern[bytes] accepted a string one, and a compiled pattern passed as a
Match.

The argument says which flavour the pattern was compiled from, so it is
checked against the pattern itself rather than against anything matched.
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 94.87% (+0.04%) from 94.83% — RavSinghChandan:check-pattern-and-match-flavour into agronholm:master

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.

2 participants