[flake8]
select = C,E,F,W
exclude =
    ./build,
    # A trick to exclude fluid/ but keep fluid/tests/, see more at
    # https://github.com/PaddlePaddle/Paddle/pull/46290#discussion_r976392010
    ./python/paddle/fluid/[!t]**,
    ./python/paddle/fluid/tra**,
    # Exclude third-party libraries
    ./python/paddle/utils/gast/**,
    # Exclude files that will be removed in the future, see more at
    # https://github.com/PaddlePaddle/Paddle/pull/46782#issuecomment-1273033731
    ./python/paddle/fluid/tests/unittests/npu/**,
    ./python/paddle/fluid/tests/unittests/mlu/**
ignore =
    E203, # Whitespace before ‘,’, ‘;’, or ‘:’, it is not compatible with black
    E402, # Module level import not at top of file
    E501, # Line too long (82 > 79 characters)
    E721, # Do not compare types, use `isinstance()`
    E722, # Do not use bare except, specify exception instead
    E731, # Do not assign a lambda expression, use a def
    E741, # Do not use variables named ‘l’, ‘O’, or ‘I’
    F405, # `name` may be undefined, or defined from star imports: `module`
    F841, # Local variable name is assigned to but never used
    W503  # Line break before binary operator, it is not compatible with black
per-file-ignores =
    # These files need tabs for testing.
    python/paddle/fluid/tests/unittests/dygraph_to_static/test_error.py:E101,W191
    python/paddle/fluid/tests/unittests/collective/fleet/test_hdfs1.py:E101,W191
    # Ignore unused imports in __init__.py
    __init__.py: F401
    # Ignore undefined variables in CMake config and some dygraph_to_static tests
    .cmake-format.py: F821
    python/paddle/fluid/tests/unittests/dygraph_to_static/test_loop.py: F821
    python/paddle/fluid/tests/unittests/dygraph_to_static/test_closure_analysis.py: F821
