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

[pre-commit] Add configuration file for pre-commit and flake8 #3467

Closed
wants to merge 5 commits into from
Closed
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
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
max-line-length = 79
select = B,C,E,F,W,T4,B9,B950
ignore = E501, W503, E203
7 changes: 7 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[settings]
multi_line_output=3
include_trailing_comma=true
force_grid_wrap=0
use_parentheses=true
ensure_newline_before_comments=true
line_length=79
33 changes: 33 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/timothycrosley/isort
rev: 5.6.4
hooks:
- id: isort
files: .*.py
- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black
args: ["--line-length", "79"]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: check-ast
- id: check-case-conflict
- id: trailing-whitespace
- id: end-of-file-fixer
- id: debug-statements
- id: check-added-large-files
- id: check-docstring-first
- id: check-yaml
exclude: conda/meta.yaml
- repo: https://github.com/PyCQA/flake8
rev: 3.8.4
hooks:
- id: flake8
- repo: https://github.com/PyCQA/bandit
rev: 1.6.2
hooks:
- id: bandit
11 changes: 11 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ add their details to the [Code Contributors](#code-contributors) section of
this file as part of their first Pull Request, and reviewers are responsible
for checking this before merging the new branch into *master*.

In order to start modifying cylc-flow and test these changes, the first step is
to call `pip install -e .[all]`. This will install the package in development
mode along all needed dependencies.

Before the first commit care should be taken to call `pre-commit install` in
order for the git pre-commit hooks to be run on commit. [pre-commit
](https://pre-commit.com) is used for code style consistency. It can also be run
manually when developing with the `pre-commit run` command. To run the hooks on
a reduced set of files, cal `pre-commit run --files` followed by one of more
files to process.

## Code Contributors

The following people have contributed to this code under the terms of
Expand Down
108 changes: 48 additions & 60 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,95 +20,83 @@
import codecs
import re
from glob import glob
from os.path import join, dirname, abspath
from os.path import abspath, dirname, join

from setuptools import setup, find_namespace_packages
from setuptools import find_namespace_packages, setup

here = abspath(dirname(__file__))


def read(*parts):
with codecs.open(join(here, *parts), 'r') as fp:
with codecs.open(join(here, *parts), "r") as fp:
return fp.read()


def find_version(*file_paths):
version_file = read(*file_paths)
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
version_file, re.M)
version_match = re.search(
r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M
)
if version_match:
return version_match.group(1)
raise RuntimeError("Unable to find version string.")


install_requires = [
'aiofiles==0.5.*',
'ansimarkup>=1.0.0',
'colorama>=0.4,<=1',
'click>=7.0',
'graphene>=2.1,<3',
'jinja2==2.11.*',
'metomi-isodatetime>=1!2.0.2, <1!2.1.0',
'protobuf==3.13.*',
'pyuv==1.4.*',
'pyzmq==19.0.*',
'psutil>=5.6.0',
'urwid==2.*'
"aiofiles==0.5.*",
"ansimarkup>=1.0.0",
"colorama>=0.4,<=1",
"click>=7.0",
"graphene>=2.1,<3",
"jinja2==2.11.*",
"metomi-isodatetime>=1!2.0.2, <1!2.1.0",
"protobuf==3.13.*",
"pyuv==1.4.*",
"pyzmq==19.0.*",
"psutil>=5.6.0",
"urwid==2.*",
]
tests_require = [
'async-timeout>=3.0.0',
'async_generator',
'codecov>=2.0.0',
'coverage>=5.0.0',
'flake8>=3.0.0',
'pycodestyle>=2.5.0',
'pytest-asyncio>=0.14.0',
'pytest-cov>=2.8.0',
'pytest-xdist>=2',
'pytest>=6',
'testfixtures>=6.11.0'
"async-timeout>=3.0.0",
"async_generator",
"codecov>=2.0.0",
"coverage>=5.0.0",
"flake8>=3.0.0",
"pycodestyle>=2.5.0",
"pytest-asyncio>=0.14.0",
"pytest-cov>=2.8.0",
"pytest-xdist>=2",
"pytest>=6",
"testfixtures>=6.11.0",
]

extra_requires = {
'empy': [
'EmPy==3.3.*'
],
'all': [],
'report-timings': [
'pandas==1.*'
],
'main_loop-log_data_store': [
'pympler',
'matplotlib'
],
'main_loop-log_main_loop': [
'matplotlib'
],
'main_loop-log_memory': [
'pympler',
'matplotlib'
]
"empy": ["EmPy==3.3.*"],
"all": [],
"report-timings": ["pandas==1.*"],
"main_loop-log_data_store": ["pympler", "matplotlib"],
"main_loop-log_main_loop": ["matplotlib"],
"main_loop-log_memory": ["pympler", "matplotlib"],
"dev": ["pre-commit"],
}
extra_requires['all'] = (
tests_require
+ list({
req
for reqs in extra_requires.values()
for req in reqs
})
extra_requires["all"] = tests_require + list(
{req for reqs in extra_requires.values() for req in reqs}
)


setup(
version=find_version("cylc", "flow", "__init__.py"),
long_description=open('README.md').read(),
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
scripts=glob(join('bin', '*')),
scripts=glob(join("bin", "*")),
packages=find_namespace_packages(include=["cylc.*"]),
package_data={
'cylc.flow': [
'etc/*.yaml', 'etc/flow*.eg', 'etc/job.sh',
'etc/syntax/*', 'etc/cylc-bash-completion'
"cylc.flow": [
"etc/*.yaml",
"etc/flow*.eg",
"etc/job.sh",
"etc/syntax/*",
"etc/cylc-bash-completion",
]
},
install_requires=install_requires,
Expand All @@ -117,6 +105,6 @@ def find_version(*file_paths):
project_urls={
"Documentation": "https://cylc.github.io/documentation.html",
"Source": "https://github.com/cylc/cylc-flow",
"Tracker": "https://github.com/cylc/cylc-flow/issues"
}
"Tracker": "https://github.com/cylc/cylc-flow/issues",
},
)
1 change: 1 addition & 0 deletions tests/functional/jinja2/filters/Jinja2Filters/truly.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.


def truly(bar):
return 'true'