diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..c97e142 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,2 @@ +include *.rst +recursive-include tests *.txt *.py diff --git a/README.rst b/README.rst index 3646340..62a8c63 100644 --- a/README.rst +++ b/README.rst @@ -22,7 +22,7 @@ List of warnings B001 ~~~~ -Do not use bare ``except:``, it also catches unexpected events " "like +Do not use bare ``except:``, it also catches unexpected events like memory errors, interrupts, system exit, and so on. Prefer ``except Exception:``. If you're sure what you're doing, be explicit and write ``except BaseException:``. @@ -35,6 +35,25 @@ Just run:: python setup.py test +OMG, this is Python 3 only! +--------------------------- + +Relax, you can run ``flake8`` with all popular plugins as a *tool* +perfectly fine under Python 3.5+ even if you want to analyze Python 2 +code. This way you'll be able to parse all of the new syntax supported +on Python 3 but also *effectively all* the Python 2 syntax at the same +time. + +If you're still invested in Python 2, there might be a small subset of +deprecated syntax that you'd have to abandon... but you're already doing +that, right? `six `_ or +`python-future `_ bridge the gaps. + +By making the code exclusively Python 3.5+, I'm able to focus on the +quality of the checks and re-use all the nice features of the new +releases (check out `pathlib `_) +instead of wasting cycles on Unicode compatiblity, etc. + License ------- @@ -44,6 +63,20 @@ MIT Change Log ---------- +16.4.2 +~~~~~~ + +* packaging herp derp + +16.4.1 +~~~~~~ + +* bugfix: include tests in the source package (to make ``setup.py test`` + work for everyone) + +* bugfix: explicitly open README.rst in UTF-8 in setup.py for systems + with other default encodings + 16.4.0 ~~~~~~ diff --git a/bugbear.py b/bugbear.py index 7fc174a..41f1162 100644 --- a/bugbear.py +++ b/bugbear.py @@ -6,7 +6,7 @@ import pep8 -__version__ = '16.4.0' +__version__ = '16.4.2' @attr.s @@ -57,6 +57,7 @@ class BugBearVisitor(ast.NodeVisitor): lines = attr.ib() node_stack = attr.ib(default=attr.Factory(list)) errors = attr.ib(default=attr.Factory(list)) + futures = attr.ib(default=attr.Factory(set)) if False: # Useful for tracing what the hell is going on. @@ -75,6 +76,7 @@ def visit_ExceptHandler(self, node): self.errors.append( B001(node.lineno, node.col_offset) ) + self.generic_visit(node) error = namedtuple('error', 'lineno col message type') @@ -86,4 +88,3 @@ def visit_ExceptHandler(self, node): "be explicit and write `except BaseException:`.", type=BugBearChecker, ) - diff --git a/setup.py b/setup.py index 5686c8e..9270f32 100644 --- a/setup.py +++ b/setup.py @@ -7,18 +7,15 @@ current_dir = os.path.abspath(os.path.dirname(__file__)) -ld_file = open(os.path.join(current_dir, 'README.rst')) -try: +with open(os.path.join(current_dir, 'README.rst'), encoding='utf8') as ld_file: long_description = ld_file.read() -finally: - ld_file.close() _version_re = re.compile(r'__version__\s+=\s+(?P.*)') -with open('bugbear.py', 'rb') as f: - version = _version_re.search(f.read().decode('utf-8')).group('version') +with open(os.path.join(current_dir, 'bugbear.py'), 'r') as f: + version = _version_re.search(f.read()).group('version') version = str(ast.literal_eval(version))