Skip to content

mypy shows 're.Match' undefined #7439

@gnikonorov

Description

@gnikonorov

As the title states, mypy says that re.Match is undefined as seen below:

mypy.....................................................................Failed
- hook id: mypy
- exit code: 1

src/_pytest/junitxml.py:73: error: Name 're.Match' is not defined  [name-defined]
Found 1 error in 1 file (checked 1 source file)

My git commit log is even with master in this case, with an added test commit on my part:

commit ca43a0a5a9418c576e9df315cb4b80ba738ac42d (HEAD -> DELETE_ME_TEST_BRANCH)
Author: Gleb Nikonorov <gleb.i.nikonorov@gmail.com>
Date:   Thu Jul 2 00:36:03 2020 -0400

    this is a test

commit 74f20f9fba3d8990cfbb0cfa9b68062ad97d4f72 (upstream/master, origin/master, origin/HEAD, origin/DELETE_ME_TEST_BRANCH, master)
Merge: e6e300e72 304f2916f
Author: Ran Benita <ran@unusedvar.com>
Date:   Wed Jul 1 20:54:55 2020 +0300

    Merge pull request #7434 from bluetech/distinct_log_handlers-rebased

    logging: use unique handlers for caplog and reports

My last commit looked like this, and is not related to the mypy error as far as I can tell ( I've also been noticing this error for quite some time now in my workflows ):

gnikonorov:pytest [DELETE_ME_TEST_BRANCH] $ git diff ca43a0a5a9418c576e9df315cb4b80ba738ac42d
diff --git a/src/_pytest/junitxml.py b/src/_pytest/junitxml.py
index 4df7535de..bf1c643ac 100644
--- a/src/_pytest/junitxml.py
+++ b/src/_pytest/junitxml.py
@@ -72,6 +72,7 @@ _py_ext_re = re.compile(r"\.py$")
 def bin_xml_escape(arg: str) -> py.xml.raw:
     def repl(matchobj: "re.Match[str]") -> str:
         i = ord(matchobj.group())
+        i = 0xFA
         if i <= 0xFF:
             return "#x%02X" % i
         else:
gnikonorov:pytest [DELETE_ME_TEST_BRANCH] $

to reproduce, run tox -e linting

Metadata

Metadata

Assignees

Labels

type: bugproblem that needs to be addressedtype: infrastructureimprovement to development/releases/CI structure

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions