Merge ~jugmac00/lazr.config:introduce-pre-commit into lazr.config:main

Proposed by Jürgen Gmach
Status: Merged
Merge reported by: Jürgen Gmach
Merged at revision: a5e91d1252a701f24f8604d8516f6f0abc0e619a
Proposed branch: ~jugmac00/lazr.config:introduce-pre-commit
Merge into: lazr.config:main
Diff against target: 201 lines (+48/-12)
13 files modified
.gitignore (+1/-0)
.pre-commit-config.yaml (+18/-0)
NEWS.rst (+4/-0)
conf.py (+2/-3)
setup.py (+1/-1)
src/lazr/config/__init__.py (+2/-2)
src/lazr/config/_config.py (+1/-1)
src/lazr/config/interfaces.py (+3/-1)
src/lazr/config/tests/testdata/bad-nonascii.conf (+0/-1)
src/lazr/config/tests/testdata/bad-redefined-key.conf (+0/-1)
src/lazr/config/tests/testdata/bad-redefined-section.conf (+0/-1)
src/lazr/config/tests/testdata/shared.conf (+0/-1)
tox.ini (+16/-0)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+411413@code.launchpad.net

Commit message

Add basic pre-commit configuration.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/.gitignore b/.gitignore
2index 66573bf..318ee2c 100644
3--- a/.gitignore
4+++ b/.gitignore
5@@ -11,3 +11,4 @@ build
6 dist
7 .tox
8 __pycache__
9+.coverage
10diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
11new file mode 100644
12index 0000000..9837b22
13--- /dev/null
14+++ b/.pre-commit-config.yaml
15@@ -0,0 +1,18 @@
16+# See https://pre-commit.com for more information
17+# See https://pre-commit.com/hooks.html for more hooks
18+repos:
19+- repo: https://github.com/pre-commit/pre-commit-hooks
20+ rev: v4.0.1
21+ hooks:
22+ - id: check-added-large-files
23+ - id: check-ast
24+ - id: end-of-file-fixer
25+ - id: check-json
26+ - id: check-merge-conflict
27+ - id: check-xml
28+ - id: check-yaml
29+ - id: debug-statements
30+- repo: https://github.com/PyCQA/flake8
31+ rev: 4.0.1
32+ hooks:
33+ - id: flake8
34diff --git a/NEWS.rst b/NEWS.rst
35index 3a909ba..f914361 100644
36--- a/NEWS.rst
37+++ b/NEWS.rst
38@@ -2,6 +2,10 @@
39 NEWS for lazr.config
40 ====================
41
42+2.2.4
43+=====
44+- Add basic pre-commit configuration.
45+
46 2.2.3 (2021-01-26)
47 ==================
48 - Fix tests with zope.interface >= 5.0.0.
49diff --git a/conf.py b/conf.py
50index e4ad315..068c1d4 100644
51--- a/conf.py
52+++ b/conf.py
53@@ -11,8 +11,7 @@
54 # All configuration values have a default; values that are commented out
55 # serve to show the default.
56
57-from __future__ import print_function
58-import sys, os
59+import os
60
61 # If extensions (or modules to document with autodoc) are in another directory,
62 # add these directories to sys.path here. If the directory is relative to the
63@@ -51,7 +50,7 @@ copyright = u'2013-2015, LAZR developers'
64 # The short X.Y version.
65 with open('src/lazr/config/_version.py') as version_file:
66 exec(version_file.read()) # sets __version__
67-version = __version__
68+version = __version__ # noqa: F821
69 # The full version, including alpha/beta/rc tags.
70 release = version
71
72diff --git a/setup.py b/setup.py
73index 327dd30..c3f11a5 100755
74--- a/setup.py
75+++ b/setup.py
76@@ -21,7 +21,7 @@ with open('src/lazr/config/_version.py') as version_file:
77
78 setup(
79 name='lazr.config',
80- version=__version__,
81+ version=__version__, # noqa: F821
82 namespace_packages=['lazr'],
83 packages=find_packages('src'),
84 package_dir={'': 'src'},
85diff --git a/src/lazr/config/__init__.py b/src/lazr/config/__init__.py
86index fd59b21..efeae25 100644
87--- a/src/lazr/config/__init__.py
88+++ b/src/lazr/config/__init__.py
89@@ -22,5 +22,5 @@ __version__
90 # While we generally frown on "*" imports, this, combined with the fact we
91 # only test code from this module, means that we can verify what has been
92 # exported.
93-from lazr.config._config import *
94-from lazr.config._config import __all__
95+from lazr.config._config import * # noqa: F401, F403
96+from lazr.config._config import __all__ # noqa: F401, F402
97diff --git a/src/lazr/config/_config.py b/src/lazr/config/_config.py
98index 9c50d6d..8069d40 100644
99--- a/src/lazr/config/_config.py
100+++ b/src/lazr/config/_config.py
101@@ -350,7 +350,7 @@ class ConfigSchema:
102 raise InvalidSectionNameError('[%s] has too many parts.' % name)
103 if self._section_name_pattern.match(section_name) is None:
104 raise InvalidSectionNameError(
105- '[%s] name does not match [\w.-]+.' % name)
106+ r'[%s] name does not match [\w.-]+.' % name)
107 return (section_name, category_name,
108 is_template, is_optional, is_master)
109
110diff --git a/src/lazr/config/interfaces.py b/src/lazr/config/interfaces.py
111index 1d0939f..0b8a497 100644
112--- a/src/lazr/config/interfaces.py
113+++ b/src/lazr/config/interfaces.py
114@@ -68,9 +68,11 @@ class UnknownSectionError(ConfigSchemaError):
115 class UnknownKeyError(ConfigSchemaError):
116 """The section has a key that is not in the schema."""
117
118+
119 class NoConfigError(ConfigSchemaError):
120 """No config has the name."""
121
122+
123 class ConfigErrors(ConfigSchemaError):
124 """The errors in a Config.
125
126@@ -123,6 +125,7 @@ class ISection(ISectionSchema):
127 :raise: AttributeError if there is no key with the name.
128 """
129
130+
131 class IConfigLoader(Interface):
132 """A configuration file loader."""
133
134@@ -211,7 +214,6 @@ class IStackableConfig(IConfigSchema):
135 extends = Attribute("The ConfigData that this config extends.")
136 overlays = Attribute("The stack of ConfigData that define this config.")
137
138-
139 def __getattr__(name):
140 """Return the named section.
141
142diff --git a/src/lazr/config/tests/testdata/bad-nonascii.conf b/src/lazr/config/tests/testdata/bad-nonascii.conf
143index 4c3896b..77bdc95 100644
144--- a/src/lazr/config/tests/testdata/bad-nonascii.conf
145+++ b/src/lazr/config/tests/testdata/bad-nonascii.conf
146@@ -1,4 +1,3 @@
147 # Non ascii character: é.
148 [test-section]
149 key1: café.
150-
151diff --git a/src/lazr/config/tests/testdata/bad-redefined-key.conf b/src/lazr/config/tests/testdata/bad-redefined-key.conf
152index ef799bb..617697d 100644
153--- a/src/lazr/config/tests/testdata/bad-redefined-key.conf
154+++ b/src/lazr/config/tests/testdata/bad-redefined-key.conf
155@@ -2,4 +2,3 @@
156 [test-section]
157 key1: original
158 key1: redefined
159-
160diff --git a/src/lazr/config/tests/testdata/bad-redefined-section.conf b/src/lazr/config/tests/testdata/bad-redefined-section.conf
161index db39304..5f5a9a9 100644
162--- a/src/lazr/config/tests/testdata/bad-redefined-section.conf
163+++ b/src/lazr/config/tests/testdata/bad-redefined-section.conf
164@@ -5,4 +5,3 @@ key2: redefined
165 #Redefine the test-section
166 [test-section]
167 key3: a value
168-
169diff --git a/src/lazr/config/tests/testdata/shared.conf b/src/lazr/config/tests/testdata/shared.conf
170index f08a251..054dd8b 100644
171--- a/src/lazr/config/tests/testdata/shared.conf
172+++ b/src/lazr/config/tests/testdata/shared.conf
173@@ -4,4 +4,3 @@
174 [section_1]
175 key2: sharing is fun
176 key5: shared value
177-
178diff --git a/tox.ini b/tox.ini
179index a5bc9ac..9bee34a 100644
180--- a/tox.ini
181+++ b/tox.ini
182@@ -8,3 +8,19 @@ commands = python -s -m nose -P lazr
183 deps =
184 nose
185 coverage
186+
187+[testenv:pre-commit]
188+commands =
189+ pre-commit run --all-files
190+deps =
191+ pre-commit
192+
193+[flake8]
194+ignore =
195+ # flake8 errors from the E category will be mostly gone after
196+ # applying black
197+ E
198+ # line break before/after binary operator
199+ # mutually exclusive
200+ W503
201+ W504

Subscribers

People subscribed via source and target branches