ambv / flake8-mypy

A plugin for flake8 integrating Mypy.
MIT License
101 stars 17 forks source link

UnicodeError on utf-8 encoded files on Windows #10

Open zsol opened 6 years ago

zsol commented 6 years ago

I tried running flake8 on black on Windows, and it fails with:

> flake8 .\black.py
Traceback (most recent call last):
  File "c:\program files (x86)\python36-32\Lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\program files (x86)\python36-32\Lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\zsolz\.virtualenvs\black-TlIYXM7K\Scripts\flake8.exe\__main__.py", line 9, in <module>
  File "c:\users\zsolz\.virtualenvs\black-tliyxm7k\lib\site-packages\flake8\main\cli.py", line 16, in main
    app.run(argv)
  File "c:\users\zsolz\.virtualenvs\black-tliyxm7k\lib\site-packages\flake8\main\application.py", line 396, in run
    self._run(argv)
  File "c:\users\zsolz\.virtualenvs\black-tliyxm7k\lib\site-packages\flake8\main\application.py", line 384, in _run
    self.run_checks()
  File "c:\users\zsolz\.virtualenvs\black-tliyxm7k\lib\site-packages\flake8\main\application.py", line 310, in run_checks
    self.file_checker_manager.run()
  File "c:\users\zsolz\.virtualenvs\black-tliyxm7k\lib\site-packages\flake8\checker.py", line 321, in run
    self.run_serial()
  File "c:\users\zsolz\.virtualenvs\black-tliyxm7k\lib\site-packages\flake8\checker.py", line 305, in run_serial
    checker.run_checks()
  File "c:\users\zsolz\.virtualenvs\black-tliyxm7k\lib\site-packages\flake8\checker.py", line 579, in run_checks
    self.run_ast_checks()
  File "c:\users\zsolz\.virtualenvs\black-tliyxm7k\lib\site-packages\flake8\checker.py", line 493, in run_ast_checks
    for (line_number, offset, text, check) in runner:
  File "c:\users\zsolz\.virtualenvs\black-tliyxm7k\lib\site-packages\flake8_mypy.py", line 192, in run
    f.write(line)
  File "c:\users\zsolz\.virtualenvs\black-tliyxm7k\lib\tempfile.py", line 483, in func_wrapper
    return func(*args, **kwargs)
  File "c:\users\zsolz\.virtualenvs\black-tliyxm7k\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2728' in position 23: character maps to <undefined>

Looks like https://github.com/ambv/flake8-mypy/commit/a7ec00d6548003da0109059240b5d996c191dcd0 fixes this but it was never released.

zsol commented 6 years ago

(Btw I'm running 17.8.0) which is on PyPI but can't see the tag in this repo