Skip to content

Problem using plugin on Windows? #17

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
eehusky opened this issue Feb 22, 2021 · 2 comments · Fixed by #34
Closed

Problem using plugin on Windows? #17

eehusky opened this issue Feb 22, 2021 · 2 comments · Fixed by #34
Labels
bug Something isn't working

Comments

@eehusky
Copy link

eehusky commented Feb 22, 2021

Ran into a problem with running this on windows. Im not entirely sure whats special about my setup that would cause this.

Relevant line from attached error message

line = "C:\\Users\\eehusky\\anaconda3\\lib\\site-packages\\_pytest\\_argcomplete.py:103:1: error: Skipping analyzing 'argcomplete.completers': found module but no type hints or library stubs"

    @classmethod
    def from_output(cls, line: str) -> "Message":
        m = cls.OUTPUT_RE.match(line)
        if not m:
>           raise ValueError("Not a valid mypy message")
E           ValueError: Not a valid mypy message

Brass tacks, It think the entire absolute path getting included and is messing with the regex.

I think it is getting hung up on the C: in the file path in mypy messages. But I am by no means a regex guru so Ill withhold judgement.

OUTPUT_RE = re.compile(
        r"^(?P<fname>[^:]+):"   # << This 
        r"(?P<lineno>[0-9]+):"
        r"((?P<colno>[0-9]+):)?"
        r" *(?P<severity>(error|note|warning)):"
        r"(?P<message>.*)$"
    )

I did mess around with this a bit and found if i removed the C: from the text it would work fine.

import os
import re
OUTPUT_RE = re.compile(
        r"^(?P<fname>[^:]+):"
        r"(?P<lineno>[0-9]+):"
        r"((?P<colno>[0-9]+):)?"
        r" *(?P<severity>(error|note|warning)):"
        r"(?P<message>.*)$"
    )

def from_output(line: str) -> "Message":
    m = OUTPUT_RE.match(line)
    if not m:
        raise ValueError("Not a valid mypy message")
    return (
        os.path.abspath(m.group("fname")),
        int(m.group("lineno")),
        int(m.group("colno")) if m.group("colno") else None,
        m.group("severity").upper(),
        m.group("message").strip(),
    )


line = "C/Users/eehusky/anaconda3/lib/site-packages/_pytest/_argcomplete.py:103:1: error: Skipping analyzing 'argcomplete.completers': found module but no type hints or library stubs"
print(from_output(line))
line = "C:/Users/eehusky/anaconda3/lib/site-packages/_pytest/_argcomplete.py:103:1: error: Skipping analyzing 'argcomplete.completers': found module but no type hints or library stubs"
print(from_output(line))

Output from above test

('C:\\Users\\eehusky\\anaconda3\\lib\\site-packages\\_pytest\\_argcomplete.py', 103, 1, 'ERROR', "Skipping analyzing 'argcomplete.completers': found module but no type hints or library stubs")
----------------------------------------------------------------------
ValueError                           Traceback (most recent call last)
<ipython-input-17-f28f32de0f3a> in <module>
     25 print(from_output(line))
     26 line = "C:/Users/eehusky/anaconda3/lib/site-packages/_pytest/_argcomplete.py:103:1: error: Skipping analyzing 'argcomplete.completers': found module but no type hints or library stubs"
---> 27 print(from_output(line))

<ipython-input-17-f28f32de0f3a> in from_output(line)
     12     m = OUTPUT_RE.match(line)
     13     if not m:
---> 14         raise ValueError("Not a valid mypy message")
     15     return (
     16         os.path.abspath(m.group("fname")),

ValueError: Not a valid mypy message

Cheers,
-Brandon

output.txt

@eehusky
Copy link
Author

eehusky commented Feb 22, 2021

I just modified my local copy of message.py and added a line = line.replace('C:','') to the beginning of from_output and now the plugin works great.

@tlambert03
Copy link

yeah, I'm seeing this too:

  cls = <class 'pytest_mypy_testing.message.Message'>
  line = 'D:\\tmp\\.tox\\py310-windows-pyqt5\\lib\\site-packages\\pydantic\\typing.py:42:5: error: Cannot assign to a type  [misc]'

....

          m = cls.OUTPUT_RE.match(line)
          if not m:
  >           raise ValueError("Not a valid mypy message")
  E           ValueError: Not a valid mypy message
  
  D:\tmp\.tox\py310-windows-pyqt5\lib\site-packages\pytest_mypy_testing\message.py:217: ValueError

@davidfritzsche davidfritzsche added the bug Something isn't working label Mar 4, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants