From 057a057d4a52537e47d2ca5f810614c90880624b Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Fri, 11 Feb 2022 14:34:02 -0300 Subject: [PATCH] [7.0.x] Add autoflake to pre-commit configuration --- .pre-commit-config.yaml | 8 ++++++++ src/_pytest/python.py | 2 -- src/_pytest/python_api.py | 1 - testing/code/test_source.py | 3 --- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 20cede3b7..7a492cf0a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,6 +20,14 @@ repos: - id: debug-statements exclude: _pytest/(debugging|hookspec).py language_version: python3 +- repo: https://github.com/myint/autoflake + rev: v1.4 + hooks: + - id: autoflake + name: autoflake + args: ["--in-place", "--remove-unused-variables", "--remove-all-unused-imports"] + language: python + files: \.py$ - repo: https://github.com/PyCQA/flake8 rev: 4.0.1 hooks: diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 0fd5702a5..608d9aefd 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -896,8 +896,6 @@ class InstanceDummy: only to ignore it; this dummy class keeps them working. This will be removed in pytest 8.""" - pass - # Note: module __getattr__ only works on Python>=3.7. Unfortunately # we can't provide this deprecation warning on Python 3.6. diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index cb72fde1e..9891946cd 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -131,7 +131,6 @@ class ApproxBase: # a numeric type. For this reason, the default is to do nothing. The # classes that deal with sequences should reimplement this method to # raise if there are any non-numeric elements in the sequence. - pass def _recursive_list_map(f, x): diff --git a/testing/code/test_source.py b/testing/code/test_source.py index 9f7be5e24..8b328a683 100644 --- a/testing/code/test_source.py +++ b/testing/code/test_source.py @@ -1,16 +1,13 @@ # flake8: noqa # disable flake check on this file because some constructs are strange # or redundant on purpose and can't be disable on a line-by-line basis -import ast import inspect import linecache import sys import textwrap from pathlib import Path -from types import CodeType from typing import Any from typing import Dict -from typing import Optional import pytest from _pytest._code import Code