for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
import codecs
from pathlib import Path
def has_bom(file_path: Path) -> bool:
with file_path.open("rb") as f:
This check looks for invalid names for a range of different identifiers.
You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.
If your project includes a Pylint configuration file, the settings contained in that file take precedence.
To find out more about Pylint, please refer to their site.
sample = f.read(4)
return (
sample[:3] == b"\xef\xbb\xbf"
or sample.startswith(codecs.BOM_UTF16_LE)
or sample.startswith(codecs.BOM_UTF16_BE)
)