Skip to content

re.MULTILINE is erroneously passed as the count positional argument in re.sub #60

@asottile-sentry

Description

@asottile-sentry

in python 3.13 with warnings enabled this becomes an error:

.venv/lib/python3.13/site-packages/email_reply_parser/__init__.py:32: in parse_reply
    return EmailReplyParser.read(text).reply
.venv/lib/python3.13/site-packages/email_reply_parser/__init__.py:22: in read
    return EmailMessage(text).read()
.venv/lib/python3.13/site-packages/email_reply_parser/__init__.py:68: in read
    self.text = re.sub('([^\n])(?=\n ?[_-]{7,})', '\\1\n', self.text, re.MULTILINE)
/opt/hostedtoolcache/Python/3.13.0/x64/lib/python3.13/re/__init__.py:203: in sub
    warnings.warn(
E   DeprecationWarning: 'count' is passed as positional argument

the code clearly didn't intend to do what it's doing -- right now it's passing count=8 because re.MULTILINE has the integer value 8

I think the parameter can be dropped entirely since the regex used does not utilize ^ or $ (which is what MULTILINE changes the behaviour of)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions