Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4f05dd5

Browse files
jorgenJørgen Lindhauntsaninja
authored
Write stubs with utf-8 encoding (#16329)
This is to ensure that you don't get encoding errors if docstrings contains odd characters like emojis. --------- Co-authored-by: Jørgen Lind <[email protected]> Co-authored-by: hauntsaninja <[email protected]>
1 parent 5d40464 commit 4f05dd5

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

mypy/stubgen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1578,7 +1578,7 @@ def generate_stub_for_py_module(
15781578
subdir = os.path.dirname(target)
15791579
if subdir and not os.path.isdir(subdir):
15801580
os.makedirs(subdir)
1581-
with open(target, "w") as file:
1581+
with open(target, "w", encoding="utf-8") as file:
15821582
file.write(output)
15831583

15841584

test-data/unit/stubgen.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3485,7 +3485,7 @@ def f2(): ...
34853485
class A:
34863486
"""class docstring
34873487

3488-
a multiline docstring"""
3488+
a multiline 😊 docstring"""
34893489
def func():
34903490
"""func docstring
34913491
don't forget to indent"""
@@ -3512,7 +3512,7 @@ class B:
35123512
class A:
35133513
"""class docstring
35143514

3515-
a multiline docstring"""
3515+
a multiline 😊 docstring"""
35163516
def func() -> None:
35173517
"""func docstring
35183518
don't forget to indent"""

0 commit comments

Comments
 (0)