Skip to content
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

add simple pre-commit config #205

Merged
merged 4 commits into from Nov 27, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions .pre-commit-config.yaml
@@ -0,0 +1,13 @@
ci:
autofix_prs: false

repos:
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: 21.10b0
hooks:
- id: black
1 change: 0 additions & 1 deletion bugbear.py
Expand Up @@ -10,7 +10,6 @@
from keyword import iskeyword

import attr

import pycodestyle

__version__ = "21.9.2"
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
@@ -0,0 +1,2 @@
[tool.isort]
profile = "black"
6 changes: 4 additions & 2 deletions setup.py
Expand Up @@ -3,9 +3,9 @@
import ast
import os
import re
from setuptools import setup
import sys

from setuptools import setup

assert sys.version_info >= (3, 6, 0), "bugbear requires Python 3.6+"

Expand Down Expand Up @@ -60,6 +60,8 @@
"Topic :: Software Development :: Quality Assurance",
],
entry_points={"flake8.extension": ["B = bugbear:BugBearChecker"]},
extras_require={"dev": ["coverage", "black", "hypothesis", "hypothesmith"]},
extras_require={
"dev": ["coverage", "black", "hypothesis", "hypothesmith", "pre-commit"]
},
project_urls={"Change Log": "https://github.com/PyCQA/flake8-bugbear#change-log"},
)
3 changes: 1 addition & 2 deletions tests/b003.py
Expand Up @@ -3,9 +3,8 @@
B003 - on line 10
"""

from os import environ
import os

from os import environ

os.environ = {}
environ = {} # that's fine, assigning a new meaning to the module-level name
Expand Down
2 changes: 1 addition & 1 deletion tests/b005.py
Expand Up @@ -18,7 +18,7 @@
s.rstrip("\n\t ") # no warning
s.rstrip(r"\n\t ") # warning

from somewhere import strip, other_type
from somewhere import other_type, strip

strip("we") # no warning
other_type().lstrip() # no warning
Expand Down
2 changes: 1 addition & 1 deletion tests/b017.py
Expand Up @@ -2,8 +2,8 @@
Should emit:
B017 - on lines 20
"""
import unittest
import asyncio
import unittest

CONSTANT = True

Expand Down
9 changes: 5 additions & 4 deletions tests/test_bugbear.py
@@ -1,15 +1,14 @@
import ast
import os
from pathlib import Path
import site
import subprocess
import sys
import unittest
from pathlib import Path

from hypothesis import HealthCheck, given, settings
from hypothesmith import from_grammar

from bugbear import BugBearChecker, BugBearVisitor
from bugbear import (
B001,
B002,
Expand All @@ -29,11 +28,13 @@
B016,
B017,
B018,
B904,
B901,
B902,
B903,
B904,
B950,
BugBearChecker,
BugBearVisitor,
)


Expand Down Expand Up @@ -64,7 +65,7 @@ def test_b003(self):
filename = Path(__file__).absolute().parent / "b003.py"
bbc = BugBearChecker(filename=str(filename))
errors = list(bbc.run())
self.assertEqual(errors, self.errors(B003(10, 0)))
self.assertEqual(errors, self.errors(B003(9, 0)))

def test_b004(self):
filename = Path(__file__).absolute().parent / "b004.py"
Expand Down