lint


Overview

The `lint` file is a shell script designed to automate the static code analysis, formatting, and type checking of the project's Python source code and related scripts. It serves as a quality assurance tool to enforce coding standards, detect potential errors early, and maintain consistent style across various Python files and scripts within the repository.

This script primarily leverages:

By running `lint`, developers and CI systems ensure that the Python codebase adheres to defined style and typing conventions before committing or deploying changes.


Detailed Explanation

Script Purpose


Script Content Breakdown

#!/usr/bin/env bash

set -eou pipefail

This ensures the script stops on errors or unset variables, making it robust for CI and local runs.


to_lint="./bench/*.py ./pysrc/orjson/__init__.pyi ./test/*.py script/pydataclass
script/pysort script/pynumpy script/pynonstr script/pycorrectness script/graph integration/init
integration/wsgi.py integration/typestubs.py integration/thread script/check-version
script/check-pypi"

ruff check ${to_lint} --fix

ruff format ${to_lint}

mypy --ignore-missing-imports --check-untyped-defs ./bench/*.py ./pysrc/orjson/__init__.pyi ./test/*.py

Parameters and Usage

./lint

Important Implementation Details


Interaction with Other Parts of the System


Example

Assuming a developer modifies some Python files in `test/` and scripts in `script/`, running:

./lint

will:


Visual Diagram

flowchart TD
    Start[Start lint script]
    DefineFiles[Define files to lint/type-check]
    RuffCheck[Ruff: lint & auto-fix]
    RuffFormat[Ruff: format code]
    MyPyCheck[Mypy: type check]
    Success[All checks passed]
    Fail[Errors found]

    Start --> DefineFiles --> RuffCheck
    RuffCheck --> RuffFormat
    RuffFormat --> MyPyCheck
    MyPyCheck -->|No errors| Success
    MyPyCheck -->|Errors| Fail

This flowchart illustrates the sequential workflow of the `lint` script: defining target files, running linting with auto-fixes, formatting, and static type checking, culminating in success or failure based on detected issues.


Summary


**End of `lint` file documentation.**