Skip to main content

A Flake8 plugin to check for files opened without an explicit encoding

Project description

flake8-file-encoding

A Flake8 plugin to check for files opened without an explicit encoding.

Why check for encoding arguments?

If you don't specify an encoding argument to the open function, then Python will use a platform-dependent default encoding—whatever locale.getpreferredencoding returns. On many platforms this is UTF-8, but on a significant minority it is something different. For example, the default encoding on Japanese Windows machines is cp932 (Microsoft's version of Shift-JIS). If you open a UTF-8 file on such a system but do not specify an encoding, then attempting to read any multi-byte characters in the file will cause a UnicodeDecodeError.

Installation

pip install flake8-file-encoding

Usage

Once this plugin is installed, Flake8 will check for missing encoding arguments along with its other checks. No special activation for this plugin is necessary. For more details on running Flake8, see the Flake8 documentation.

Errors

Code Message
FEN001 open() call has no encoding argument

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for flake8-file-encoding, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size flake8_file_encoding-0.1.0-py3-none-any.whl (3.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size flake8-file-encoding-0.1.0.tar.gz (2.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page