Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Commit

Permalink
Installing linting, improved CI, precommit hooks, dependency fixing, …
Browse files Browse the repository at this point in the history
…coverage (#20)
  • Loading branch information
cbrews authored Jun 22, 2021
1 parent 04f2fdd commit 1bfd261
Show file tree
Hide file tree
Showing 32 changed files with 560 additions and 321 deletions.
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[run]
omit = ignition/python/*
8 changes: 7 additions & 1 deletion .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ jobs:
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: isort
run: |
isort . --check-only --diff
- name: pylint
run: |
pylint examples ignition tests setup.py --rcfile=.pylintrc
- name: Test with pytest
run: |
pytest
pytest --cov=ignition
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
repos:
- repo: https://github.com/google/yapf
rev: v0.31.0
hooks:
- id: yapf
args: [-i]
- repo: https://github.com/pycqa/isort
rev: 5.9.1
hooks:
- id: isort
- repo: https://github.com/pycqa/pylint
rev: v2.8.3
hooks:
- id: pylint
args: [--rcfile=.pylintrc]
204 changes: 204 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
[MASTER]
ignore=CVS,
python,
jobs=1
limit-inference-results=100
persistent=yes
suggestion-mode=yes
unsafe-load-any-extension=no


[MESSAGES CONTROL]
disable=print-statement,
fixme,
parameter-unpacking,
unpacking-in-except,
old-raise-syntax,
duplicate-code,
logging-fstring-interpolation,
logging-format-interpolation,
invalid-name,
no-self-use,
unused-wildcard-import,
wildcard-import,
too-many-arguments,
too-few-public-methods,
too-many-return-statements,
backtick,
long-suffix,
old-ne-operator,
old-octal-literal,
import-star-module-level,
non-ascii-bytes-literal,
raw-checker-failed,
bad-inline-option,
locally-disabled,
file-ignored,
suppressed-message,
useless-suppression,
deprecated-pragma,
use-symbolic-message-instead,
apply-builtin,
basestring-builtin,
buffer-builtin,
cmp-builtin,
coerce-builtin,
execfile-builtin,
file-builtin,
long-builtin,
raw_input-builtin,
reduce-builtin,
standarderror-builtin,
unicode-builtin,
xrange-builtin,
coerce-method,
delslice-method,
getslice-method,
setslice-method,
no-absolute-import,
old-division,
dict-iter-method,
dict-view-method,
next-method-called,
metaclass-assignment,
indexing-exception,
raising-string,
reload-builtin,
oct-method,
hex-method,
nonzero-method,
cmp-method,
input-builtin,
round-builtin,
intern-builtin,
unichr-builtin,
map-builtin-not-iterating,
zip-builtin-not-iterating,
range-builtin-not-iterating,
filter-builtin-not-iterating,
using-cmp-argument,
eq-without-hash,
div-method,
idiv-method,
rdiv-method,
exception-message-attribute,
invalid-str-codec,
sys-max-int,
bad-python3-import,
deprecated-string-function,
deprecated-str-translate-call,
deprecated-itertools-function,
deprecated-types-field,
next-method-defined,
dict-items-not-iterating,
dict-keys-not-iterating,
dict-values-not-iterating,
deprecated-operator-function,
deprecated-urllib-function,
xreadlines-attribute,
deprecated-sys-function,
exception-escape,
comprehension-escape
enable=c-extension-no-member

[REFACTORING]
max-nested-blocks=5
never-returning-functions=sys.exit,argparse.parse_error

[LOGGING]
logging-modules=logging

[TYPECHECK]
contextmanager-decorators=contextlib.contextmanager
generated-members=
ignore-mixin-members=yes
ignore-none=yes
ignore-on-opaque-inference=yes
ignored-classes=optparse.Values,thread._local,_thread._local
ignored-modules=
missing-member-hint=yes
missing-member-hint-distance=1
missing-member-max-choices=1

[VARIABLES]
allow-global-unused-variables=yes
callbacks=cb_,
_cb
dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_
ignored-argument-names=_.*|^ignored_|^unused_
init-import=no
redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io

[FORMAT]
ignore-long-lines=^\s*(# )?<?https?://\S+>?$
indent-after-paren=2
indent-string=' '
max-line-length=140
single-line-class-stmt=no
single-line-if-stmt=no

[SIMILARITIES]
ignore-comments=yes
ignore-docstrings=yes
ignore-imports=no
min-similarity-lines=4

[BASIC]
argument-naming-style=snake_case
attr-naming-style=snake_case
bad-names=foo,
bar,
baz,
toto,
tutu,
tata
bad-names-rgxs=
class-attribute-naming-style=any
class-const-naming-style=UPPER_CASE
class-naming-style=PascalCase
const-naming-style=UPPER_CASE
docstring-min-length=-1
function-naming-style=snake_case
good-names=i,
j,
k,
ex,
Run,
_
include-naming-hint=no
inlinevar-naming-style=any
method-naming-style=snake_case
module-naming-style=snake_case
no-docstring-rgx=^_
property-classes=abc.abstractproperty
variable-naming-style=snake_case


[STRING]
check-quote-consistency=no
check-str-concat-over-line-jumps=no


[IMPORTS]
allow-wildcard-with-all=no
analyse-fallback-blocks=no
deprecated-modules=optparse,tkinter.tix
known-third-party=enchant

[CLASSES]
check-protected-access-in-special-methods=no
defining-attr-methods=__init__,
__new__,
setUp,
__post_init__
exclude-protected=_asdict,
_fields,
_replace,
_source,
_make
valid-classmethod-first-arg=cls
valid-metaclass-classmethod-first-arg=cls

[EXCEPTIONS]
overgeneral-exceptions=BaseException,
Exception
3 changes: 3 additions & 0 deletions .yapfignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ignition/python
venv
build
9 changes: 8 additions & 1 deletion docs/developer.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,14 @@ $ pip -r requirements.txt
```

### Code Formatting Style
No linting or requirements are currently enforced. I understand my style is a bit divergent from standard Python style; I hope to clean this up soon.
We are using a custom linting style enforced by `pylint` and `yapf`. In order to make your life easier, I've
included pre-commit hooks that you can install once you've downloaded and installed requirements.

```
$ pre-commit install
```

Code style will be updated on commit.

### Unit Testing
Unit testing is build through `pytest`. Unit test can be run by:
Expand Down
2 changes: 1 addition & 1 deletion examples/advanced-usage.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'''
This Source Code Form is subject to the terms of the
Mozilla Public License, v. 2.0. If a copy of the MPL
was not distributed with this file, You can obtain one
was not distributed with this file, You can obtain one
at http://mozilla.org/MPL/2.0/.
'''

Expand Down
4 changes: 2 additions & 2 deletions examples/simple-usage.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'''
This Source Code Form is subject to the terms of the
Mozilla Public License, v. 2.0. If a copy of the MPL
was not distributed with this file, You can obtain one
was not distributed with this file, You can obtain one
at http://mozilla.org/MPL/2.0/.
'''

Expand All @@ -11,4 +11,4 @@
response = ignition.request('//gemini.circumlunar.space')

# Print full response from remote capsule
print(response)
print(response)
4 changes: 2 additions & 2 deletions examples/using-referer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'''
This Source Code Form is subject to the terms of the
Mozilla Public License, v. 2.0. If a copy of the MPL
was not distributed with this file, You can obtain one
was not distributed with this file, You can obtain one
at http://mozilla.org/MPL/2.0/.
'''

Expand All @@ -10,4 +10,4 @@
response1 = ignition.request('//gemini.circumlunar.space')
response2 = ignition.request('software', referer=response1.url)

print(response2)
print(response2)
Loading

0 comments on commit 1bfd261

Please sign in to comment.