diff --git a/flake8_leading_blank_lines.py b/flake8_leading_blank_lines.py new file mode 100644 index 0000000..b4236f0 --- /dev/null +++ b/flake8_leading_blank_lines.py @@ -0,0 +1,21 @@ +import token + +__version__ = '1.0.1' + + +def plugin(tree, file_tokens): + try: + first = file_tokens[0] + except IndexError: + return + if first.type == token.NL: + yield ( + first.start[0], + first.start[1], + 'LBL001: Blank line at start of file', + None + ) + + +plugin.name = 'flake8-leading-blank-lines' +plugin.version = __version__ diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..2a9acf1 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal = 1 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..128a4ea --- /dev/null +++ b/setup.py @@ -0,0 +1,51 @@ +import setuptools + + +def get_version(): + with open('flake8_leading_blank_lines.py') as f: + lines = [line.strip() for line in f if line.startswith('__version__')] + + for line in lines: + _, versionstr = line.split('=', 1) + return versionstr.strip(' "\'') + + raise Exception("__version__ not found in flake8_leading_blank_lines.py") + + +with open("README.md", "r", encoding="utf-8") as fh: + long_description = fh.read() + + +setuptools.setup( + name="flake8-leading-blank-lines", + license="MIT", + version=get_version(), + description="A flake8 plugin to detect blank lines at the start of a file", + long_description=long_description, + long_description_content_type="text/markdown", + author="Baptiste Mispelon", + author_email="bmispelon@gmail.com", + url="https://github.com/bmispelon/flake8-leading-blank-lines", + project_urls={ + "Bug Tracker": "https://github.com/bmispelon/flake8-leading-blank-lines/issues", + }, + py_modules=["flake8_leading_blank_lines"], + install_requires=[ + "flake8 > 3.0.0", + ], + entry_points={ + 'flake8.extension': [ + 'LBL001 = flake8_leading_blank_lines:plugin', + ], + }, + classifiers=[ + "Framework :: Flake8", + "Environment :: Console", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: Software Development :: Quality Assurance", + ], +)