Skip to content

MAINT: Remove encoding declarations: # -*- coding: utf-8 -*- #20060

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 6, 2021

Conversation

DimitriPapadopoulos
Copy link
Contributor

In Python 3, the default source file encoding is UTF-8.
Copy link
Member

@WarrenWeckesser WarrenWeckesser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@seberg seberg merged commit 8d2ddb5 into numpy:main Oct 6, 2021
@seberg
Copy link
Member

seberg commented Oct 6, 2021

Thanks, agreed it should serve no purpose anymore.

@DimitriPapadopoulos DimitriPapadopoulos deleted the coding_utf-8 branch October 7, 2021 05:55
@DimitriPapadopoulos
Copy link
Contributor Author

The Python interpreter may use UTF-8 by default, but it remains possible that some IDEs might rely on the encoding declaration.

This issue has been raised in scikit-learn/scikit-learn#21260 (comment). I believe this is overly cautious, especially since the majority of UTF-8 files already lack the # -*- coding: utf-8 -*-. Yet I thought I'd mention this here.

@DimitriPapadopoulos
Copy link
Contributor Author

I have modified 6 ASCII files and 3 UTF-8 files:

$ file doc/neps/conf.py 
doc/neps/conf.py: ASCII text
$ 
$ file doc/source/conf.py 
doc/source/conf.py: Python script, ASCII text executable
$ 
$ file numpy/core/tests/test_arrayprint.py 
numpy/core/tests/test_arrayprint.py: Python script, UTF-8 Unicode text executable
$ 
$ file numpy/core/tests/test_scalarinherit.py 
numpy/core/tests/test_scalarinherit.py: Python script, ASCII text executable
$ 
$ file numpy/core/tests/test_scalarprint.py 
numpy/core/tests/test_scalarprint.py: Python script, ASCII text executable
$ 
$ file numpy/doc/constants.py 
numpy/doc/constants.py: Python script, UTF-8 Unicode text executable
$ 
$ file numpy/ma/bench.py 
numpy/ma/bench.py: Python script, UTF-8 Unicode text executable
$ 
$ file tools/changelog.py 
tools/changelog.py: Python script, ASCII text executable
$ 
$ file tools/download-wheels.py 
tools/download-wheels.py: Python script, ASCII text executable
$ 

NumPy contains 13 UTF-8 *.py files, which means 13 - 3 = 10 of them already lack an encoding declaration:

$ find -name \*.py -exec file {} + | fgrep UTF-8
./numpy/testing/print_coercion_tables.py:                         Python script, UTF-8 Unicode text executable
./numpy/doc/constants.py:                                         Python script, UTF-8 Unicode text executable
./numpy/ma/bench.py:                                              Python script, UTF-8 Unicode text executable
./numpy/polynomial/_polybase.py:                                  Python script, UTF-8 Unicode text executable
./numpy/polynomial/tests/test_printing.py:                        Python script, UTF-8 Unicode text executable
./numpy/polynomial/polynomial.py:                                 Python script, UTF-8 Unicode text executable
./numpy/polynomial/__init__.py:                                   Python script, UTF-8 Unicode text executable
./numpy/core/tests/test_casting_unittests.py:                     Python script, UTF-8 Unicode text executable
./numpy/core/tests/test_datetime.py:                              Python script, UTF-8 Unicode text executable
./numpy/core/tests/test_arrayprint.py:                            Python script, UTF-8 Unicode text executable
./numpy/core/tests/test_regression.py:                            Python script, UTF-8 Unicode text executable
./doc/neps/tools/build_index.py:                                  Python script, UTF-8 Unicode text executable
./benchmarks/benchmarks/bench_linalg.py:                          Python script, UTF-8 Unicode text executable
$ 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants