Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log

## Unreleased

Bugfixes:
* Specify encoding when opening files. Prevents `UnicodeDecodeError` on Windows
when the file contains non-CP1252 characters.
Contributed by [Avasam](https://github.com/Avasam).

## 22.10.0

Bugfixes:
Expand Down Expand Up @@ -149,7 +156,7 @@ Features:

* extend Y001 to cover `ParamSpec` and `TypeVarTuple` in addition to `TypeVar`
* detect usage of non-integer indices in `sys.version_info` checks
* extend Y010 to check async functions in addition to normal functions
* extend Y010 to check async functions in addition to normal functions
* extend Y010 to cover what was previously included in Y090 (disallow
assignments in `__init__` methods) and Y091 (disallow `raise`
statements). The previous checks were disabled by default.
Expand Down
2 changes: 1 addition & 1 deletion pyi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1774,7 +1774,7 @@ def run(self, tree: ast.AST) -> Iterator[Error]:


def _check_for_type_comments(path: Path) -> Iterator[Error]:
stublines = path.read_text().splitlines()
stublines = path.read_text(encoding="UTF-8").splitlines()
for lineno, line in enumerate(stublines, start=1):
cleaned_line = line.strip()

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@


current_dir = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(current_dir, "README.md"), encoding="utf8") as ld_file:
with open(os.path.join(current_dir, "README.md"), encoding="UTF-8") as ld_file:
long_description = ld_file.read()


_version_re = re.compile(r"__version__\s+=\s+(?P<version>.*)")


with open(os.path.join(current_dir, "pyi.py"), "r") as f:
with open(os.path.join(current_dir, "pyi.py"), "r", encoding="UTF-8") as f:
version = _version_re.search(f.read()).group("version")
version = str(ast.literal_eval(version))

Expand Down
2 changes: 1 addition & 1 deletion tests/test_pyi_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_pyi_file(path):
flags = []
expected_output = ""

with open(path) as file:
with open(path, encoding="UTF-8") as file:
file_contents = file.read()

for lineno, line in enumerate(file_contents.splitlines(), start=1):
Expand Down