Skip to content

Commit

Permalink
Use pre-commit for linting.
Browse files Browse the repository at this point in the history
  • Loading branch information
sallner authored and Michael Howitz committed Jan 29, 2021
1 parent c25b62c commit 293118a
Show file tree
Hide file tree
Showing 21 changed files with 179 additions and 75 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Lint

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
type: [ "opened", "reopened", "synchronize" ]

env:
FORCE_COLOR: 1

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Cache
uses: actions/cache@v2
with:
path: |
~/.cache/pip
~/.cache/pre-commit
key:
lint-v1-${{ hashFiles('**/setup.py') }}-${{ hashFiles('**/.pre-commit-config.yaml') }}
restore-keys: |
lint-v1-
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install pre-commit
- name: Lint
run: |
pre-commit run --all-files --show-diff-on-failure
env:
PRE_COMMIT_COLOR: always
46 changes: 46 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: fix-encoding-pragma
args: [--remove]
- id: check-yaml
- id: debug-statements
language_version: python3
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
language_version: python3
additional_dependencies: [flake8-typing-imports==1.9.0]
args: [--per-file-ignores=src/gocept/pytestlayer/tests/test_integration.py:E501]
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: v1.5.4
hooks:
- id: autopep8
- repo: https://github.com/timothycrosley/isort
rev: 5.7.0
hooks:
- id: isort
args: [--filter-files]
files: \.py$
- repo: local
hooks:
- id: rst
name: rst
entry: rst-lint --encoding utf-8
exclude: ./doc/*
# We have Sphinx directives in the docs. This cannot be validated
# here. We therefore include two rst-linter. They complement each
# other. This regex matches all *.rst not in the doc/ folder.
files: ^[^(doc)].*rst
language: python
additional_dependencies: [pygments, restructuredtext_lint]
- repo: https://github.com/myint/rstcheck
rev: '' # Use the sha / tag you want to point at
hooks:
- id: rstcheck
args: [--ignore-messages, Duplicate implicit target name ]
50 changes: 25 additions & 25 deletions doc/_themes/jinja/static/jinja.css_t
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
{% set sidebar_width = '220px' %}
{% set font_family = 'Georgia, serif' %}
{% set header_font_family = 'Crimson Text, ' ~ font_family %}

@import url("basic.css");

/* -- page layout ----------------------------------------------------------- */

body {
font-family: {{ font_family }};
font-size: 17px;
Expand Down Expand Up @@ -44,7 +44,7 @@ div.sphinxsidebar {
hr {
border: 1px solid #B1B4B6;
}

div.body {
background-color: #fff;
color: #333;
Expand All @@ -55,7 +55,7 @@ img.floatingflask {
padding: 0 0 10px 10px;
float: right;
}

div.footer {
width: {{ page_width }};
margin: 20px auto 30px auto;
Expand All @@ -71,7 +71,7 @@ div.footer a {
div.related {
display: none;
}

div.sphinxsidebar a {
color: #444;
text-decoration: none;
Expand All @@ -81,7 +81,7 @@ div.sphinxsidebar a {
div.sphinxsidebar a:hover {
border-bottom: 1px solid #999;
}

div.sphinxsidebar {
font-size: 15px;
line-height: 1.5;
Expand All @@ -96,7 +96,7 @@ div.sphinxsidebarwrapper p.logo {
margin: 0;
text-align: center;
}

div.sphinxsidebar h3,
div.sphinxsidebar h4 {
font-family: {{ font_family }};
Expand All @@ -110,7 +110,7 @@ div.sphinxsidebar h4 {
div.sphinxsidebar h4 {
font-size: 20px;
}

div.sphinxsidebar h3 a {
color: #444;
}
Expand All @@ -121,7 +121,7 @@ div.sphinxsidebar p.logo a:hover,
div.sphinxsidebar h3 a:hover {
border: none;
}

div.sphinxsidebar p {
color: #555;
margin: 10px 0;
Expand All @@ -132,7 +132,7 @@ div.sphinxsidebar ul {
padding: 0;
color: #000;
}

div.sphinxsidebar input {
border: 1px solid #ccc;
font-family: {{ font_family }};
Expand All @@ -142,19 +142,19 @@ div.sphinxsidebar input {
div.sphinxsidebar form.search input[name="q"] {
width: 130px;
}

/* -- body styles ----------------------------------------------------------- */

a {
color: #00a;
text-decoration: underline;
}

a:hover {
color: #00d;
text-decoration: underline;
}

div.body h1,
div.body h2,
div.body h3,
Expand All @@ -167,25 +167,25 @@ div.body h6 {
padding: 0;
color: black;
}

div.body h1 { margin-top: 0; padding-top: 0; font-size: 240%; }
div.body h2 { font-size: 180%; }
div.body h3 { font-size: 150%; }
div.body h4 { font-size: 130%; }
div.body h5 { font-size: 100%; }
div.body h6 { font-size: 100%; }

a.headerlink {
color: #ddd;
padding: 0 4px;
text-decoration: none;
}

a.headerlink:hover {
color: #444;
background: #eaeaea;
}

div.body p, div.body dd, div.body li {
line-height: 1.4em;
}
Expand Down Expand Up @@ -232,20 +232,20 @@ div.note {
background-color: #eee;
border: 1px solid #ccc;
}

div.seealso {
background-color: #ffc;
border: 1px solid #ff6;
}

div.topic {
background-color: #eee;
}

p.admonition-title {
display: inline;
}

p.admonition-title:after {
content: ":";
}
Expand Down Expand Up @@ -339,7 +339,7 @@ ul, ol {
margin: 10px 0 10px 30px;
padding: 0;
}

pre {
background: #eee;
padding: 7px 30px;
Expand All @@ -356,7 +356,7 @@ dl dl pre {
margin-left: -90px;
padding-left: 90px;
}

tt {
background-color: #E8EFF0;
color: #222;
Expand Down
2 changes: 0 additions & 2 deletions doc/api.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
Selenese API
------------

.. _general-information:

General information
~~~~~~~~~~~~~~~~~~~

Expand Down
3 changes: 2 additions & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
import os
import sys


# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down
8 changes: 8 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,11 @@ upload-dir = doc/_build/html

[bdist_wheel]
universal = 0

[isort]
lines_between_sections = 0
lines_after_imports = 2
no_sections = True
from_first = True
lines_between_types = 0
force_single_line = True
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from setuptools import setup, find_packages
from setuptools import find_packages
from setuptools import setup


install_requires = [
'gocept.httpserverlayer >= 3',
Expand Down
15 changes: 12 additions & 3 deletions src/gocept/selenium/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
from .util import skipUnlessBrowser # noqa
from .webdriver import Layer as WebdriverLayer # noqa
from .webdriver import WebdriverSeleneseLayer, WebdriverSeleneseTestCase # noqa
from .util import skipUnlessBrowser
from .webdriver import Layer as WebdriverLayer
from .webdriver import WebdriverSeleneseLayer
from .webdriver import WebdriverSeleneseTestCase


__all__ = [
'skipUnlessBrowser',
'WebdriverLayer',
'WebdriverSeleneseLayer',
'WebdriverSeleneseTestCase',
]
1 change: 0 additions & 1 deletion src/gocept/selenium/grok/ftesting.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,3 @@
<grant role="zope.Manager" principal="zope.mgr" />

</configure>

5 changes: 2 additions & 3 deletions src/gocept/selenium/grok/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
import transaction

import gocept.selenium.grok
import gocept.selenium.grok.fixtures

import gocept.selenium.tests.isolation
import transaction


test_layer = gocept.selenium.grok.Layer(gocept.selenium.grok)

Expand Down
3 changes: 2 additions & 1 deletion src/gocept/selenium/screenshot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from PIL import Image, ImageChops
from PIL import Image
from PIL import ImageChops
import inspect
import itertools
import math
Expand Down
8 changes: 4 additions & 4 deletions src/gocept/selenium/scripts/converthtmltests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
Convert HTML selenium tests to gocept.selenium.seleniumrcd test cases.
"""

import re
import os
import glob
from string import Template
from optparse import OptionParser
from string import Template
from xml.etree import ElementTree as HTMLTreeBuilder
from xml.etree.ElementTree import QName
import glob
import os
import re


module_template = Template('''\
Expand Down
Loading

0 comments on commit 293118a

Please sign in to comment.