Back to Intellij Community

coding=utf-8

python/python-psi-impl/resources/inspectionDescriptions/PyNonAsciiCharInspection.html

2025.3-rc-2469 B
Original Source

Reports cases in Python 2 when a file contains non-ASCII characters and does not have an encoding declaration at the top.

Example:

class A(object):
    # №5
    def __init__ (self):
        pass

In this example, the IDE reports a non-ASCII symbol in a comment and a lack of encoding declaration. Apply the proposed quick-fix to add a missing encoding declaration:

# coding=utf-8
class A(object)
    # №5
    def __init__ (self):
        pass