Skip to content

STYLE add vulture hook #45173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ repos:
hooks:
- id: absolufy-imports
files: ^pandas/
- repo: https://github.com/jendrikseipp/vulture
rev: 'v2.3'
hooks:
- id: vulture
entry: python scripts/run_vulture.py
pass_filenames: true
require_serial: false
- repo: https://github.com/python/black
rev: 21.12b0
hooks:
Expand Down
3 changes: 1 addition & 2 deletions pandas/tests/frame/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1285,8 +1285,7 @@ def test_constructor_empty_list(self):

# Empty generator: list(empty_gen()) == []
def empty_gen():
return
yield
yield from ()

df = DataFrame(empty_gen(), columns=["A", "B"])
tm.assert_frame_equal(df, expected)
Expand Down
21 changes: 21 additions & 0 deletions scripts/run_vulture.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""Look for unreachable code."""

import argparse
import sys

from vulture import Vulture

if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("files", nargs="*")
args = parser.parse_args()

v = Vulture()
v.scavenge(args.files)
ret = 0
for item in v.get_unused_code(min_confidence=100):
if item.typ == "unreachable_code":
print(item.get_report())
ret = 1

sys.exit(ret)