-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement code style enforcement (#12)
* Put the flake8 config into a separate file * Make flake8 better explained * Configure isort * Make the source compat w/ wemake-python-styleguide * Add wemake-python-styleguide badge to README * Fix linter offences * Integrate pre-commit tool * Integrate tox * Drop-in a yamllint config * Integrate Travis CI
- Loading branch information
Showing
16 changed files
with
251 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[flake8] | ||
filename = | ||
# Normal Python files (default): | ||
*.py, | ||
# Cython files: | ||
*.pyx | ||
per-file-ignores = | ||
# Exclude errors that don't make sense for Cython | ||
lib/pylibssh/*.pyx: E225,E227,E999 | ||
max-line-length = 160 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# https://github.com/timothycrosley/isort/wiki/isort-Settings | ||
[settings] | ||
# Should be: 80 - 1 | ||
line_length = 79 | ||
# force_to_top=file1.py,file2.py | ||
# skip=file3.py,file4.py | ||
# known_future_library=future,pies | ||
# known_standard_library=std,std2 | ||
# known_third_party=randomthirdparty | ||
# known_first_party=mylib1,mylib2 | ||
indent = ' ' | ||
# https://github.com/timothycrosley/isort#multi-line-output-modes | ||
multi_line_output = 5 | ||
# length_sort = 1 | ||
# forced_separate = django.contrib,django.utils | ||
default_section = FIRSTPARTY | ||
no_lines_before = LOCALFOLDER |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
--- | ||
repos: | ||
- repo: git://github.com/pre-commit/mirrors-isort | ||
rev: v4.3.21 | ||
hooks: | ||
- id: isort | ||
|
||
- repo: git://github.com/asottile/add-trailing-comma | ||
rev: v0.7.1 | ||
hooks: | ||
- id: add-trailing-comma | ||
|
||
- repo: git://github.com/Lucas-C/pre-commit-hooks | ||
rev: v1.1.6 | ||
hooks: | ||
- id: remove-tabs | ||
|
||
- repo: git://github.com/pre-commit/pre-commit-hooks | ||
rev: v2.3.0 | ||
hooks: | ||
# Side-effects: | ||
- id: trailing-whitespace | ||
- id: check-merge-conflict | ||
- id: double-quote-string-fixer | ||
- id: end-of-file-fixer | ||
- id: requirements-txt-fixer | ||
|
||
# Non-modifying checks: | ||
- id: name-tests-test | ||
- id: check-added-large-files | ||
- id: check-byte-order-marker | ||
- id: check-case-conflict | ||
# disabled due to pre-commit/pre-commit-hooks#159 | ||
#- id: check-docstring-first | ||
- id: check-json | ||
- id: check-symlinks | ||
- id: check-yaml | ||
# args: | ||
# - --unsafe | ||
- id: detect-private-key | ||
|
||
# Heavy checks: | ||
- id: check-ast | ||
- id: debug-statements | ||
- id: flake8 | ||
additional_dependencies: | ||
- flake8-2020 | ||
- flake8-pytest-style | ||
- wemake-python-styleguide | ||
|
||
- repo: git://github.com/Lucas-C/pre-commit-hooks-markup | ||
rev: v1.0.0 | ||
hooks: | ||
- id: rst-linter | ||
files: >- | ||
^.*\.rst$ | ||
- repo: git://github.com/pycqa/pydocstyle.git | ||
rev: 4.0.1 | ||
hooks: | ||
- id: pydocstyle | ||
|
||
# - repo: local | ||
# hooks: | ||
# - id: pylint | ||
# language: system | ||
# name: PyLint | ||
# files: \.py$ | ||
# entry: python -m pylint | ||
# args: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
language: python | ||
|
||
jobs: | ||
fast_finish: true | ||
include: | ||
- name: pre-commit.com tool linters | ||
python: 3.8 | ||
env: | ||
TOXENV: lint | ||
|
||
cache: | ||
pip: true | ||
directories: | ||
- $HOME/.cache/pre-commit | ||
- $HOME/.pre-commit | ||
- $HOME/virtualenv/python$(python -c 'import platform; print(platform.python_version())') | ||
- $HOME/Library/Caches/Homebrew | ||
|
||
install: | ||
- python -m pip install tox | ||
- python -m tox --notest # Pre-populate a virtualenv with dependencies | ||
|
||
script: | ||
- python -m tox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
indentation: | ||
indent-sequences: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ Changelog | |
********* | ||
|
||
0.0.1 Unreleased | ||
============== | ||
================ | ||
|
||
0.0.1.dev0 | ||
========== | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
"""Python bindings for libssh.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
"""Cython interface definitions for libssh.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,39 @@ | ||
import sys | ||
# -*- coding: utf-8 -*- | ||
|
||
"""Dist metadata setup.""" | ||
|
||
import os | ||
import logging | ||
import sys | ||
|
||
from setuptools import setup, find_packages | ||
from setuptools import find_packages, setup | ||
from setuptools.extension import Extension | ||
|
||
from Cython.Build import cythonize | ||
|
||
LIB_NAME = 'ssh' | ||
|
||
|
||
sys.path.insert(0, os.path.abspath('lib')) | ||
|
||
setup( | ||
name="pylibssh", | ||
version="0.0.1.dev0", | ||
ext_modules=cythonize([Extension("pylibssh.session", ["lib/pylibssh/session.pyx"], libraries=["ssh"]), | ||
Extension("pylibssh.channel", ["lib/pylibssh/channel.pyx"], libraries=["ssh"]), | ||
Extension("pylibssh.sftp", ["lib/pylibssh/sftp.pyx"], libraries=["ssh"]), | ||
Extension("pylibssh.errors", ["lib/pylibssh/errors.pyx"], libraries=["ssh"])]), | ||
name='pylibssh', | ||
version='0.0.1.dev0', | ||
ext_modules=cythonize([ | ||
Extension('pylibssh.session', ['lib/pylibssh/session.pyx'], libraries=[LIB_NAME]), | ||
Extension('pylibssh.channel', ['lib/pylibssh/channel.pyx'], libraries=[LIB_NAME]), | ||
Extension('pylibssh.sftp', ['lib/pylibssh/sftp.pyx'], libraries=[LIB_NAME]), | ||
Extension('pylibssh.errors', ['lib/pylibssh/errors.pyx'], libraries=[LIB_NAME]), | ||
]), | ||
package_dir={'': 'lib'}, | ||
packages=find_packages('lib'), | ||
description="Python bindings for libssh client", | ||
description='Python bindings for libssh client', | ||
classifiers=[ | ||
"Development Status :: 2 - Pre-Alpha", | ||
"License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)", | ||
"Operating System :: MacOS", | ||
"Operating System :: POSIX :: Linux", | ||
"Programming Language :: Cython", | ||
"Topic :: Software Development :: Libraries :: Python Modules", | ||
"Topic :: Security", | ||
'Development Status :: 2 - Pre-Alpha', | ||
'License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)', | ||
'Operating System :: MacOS', | ||
'Operating System :: POSIX :: Linux', | ||
'Programming Language :: Cython', | ||
'Topic :: Software Development :: Libraries :: Python Modules', | ||
'Topic :: Security', | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
"""Tests suite for channel.""" | ||
|
||
import unittest | ||
|
||
|
||
class TestChannel(unittest.TestCase): | ||
pass | ||
"""Tests collection for channel.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
"""Tests suite for session.""" | ||
|
||
import unittest | ||
|
||
|
||
class TestSession(unittest.TestCase): | ||
pass | ||
"""Tests collection for session.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
"""Tests suite for sftp.""" | ||
|
||
import unittest | ||
|
||
|
||
class TestSftp(unittest.TestCase): | ||
pass | ||
"""Tests collection for sftp.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,54 @@ | ||
[flake8] | ||
filename = *.py, *.pyx | ||
per-file-ignores = lib/pylibssh/*:E225,E227,E999 | ||
max-line-length = 160 | ||
[tox] | ||
envlist = python | ||
minversion = 3.13.0 | ||
requires = | ||
setuptools >= 40.9.0 | ||
pip >= 19.0.3 | ||
# tox-venv >= 0.4.0 | ||
isolated_build = true | ||
|
||
|
||
[testenv] | ||
isolated_build = true | ||
usedevelop = false | ||
deps = | ||
pytest | ||
commands = | ||
{envpython} -m pytest {posargs:} | ||
|
||
|
||
[testenv:build-dists] | ||
isolated_build = true | ||
# `usedevelop = true` overrides `skip_install` instruction, it's unwanted | ||
usedevelop = false | ||
# don't install octomachinery itself in this env | ||
skip_install = true | ||
deps = | ||
pep517 >= 0.5.0 | ||
setenv = | ||
PYPI_UPLOAD = true | ||
commands = | ||
rm -rfv {toxinidir}/dist/ | ||
{envpython} -m pep517.build \ | ||
--source \ | ||
--binary \ | ||
--out-dir {toxinidir}/dist/ \ | ||
{toxinidir} | ||
whitelist_externals = | ||
rm | ||
|
||
|
||
[testenv:lint] | ||
basepython = python3 | ||
commands = | ||
{envpython} -m pre_commit run --show-diff-on-failure {posargs:--all-files} | ||
|
||
# Print out the advise of how to install pre-commit from this env into Git: | ||
-{envpython} -c \ | ||
'cmd = "{envpython} -m pre_commit install"; scr_width = len(cmd) + 10; sep = "=" * scr_width; cmd_str = " $ " + cmd; '\ | ||
'print("\n" + sep + "\nTo install pre-commit hooks into the Git repo, run:\n\n" + cmd_str + "\n\n" + sep + "\n")' | ||
deps = | ||
pre-commit | ||
# pylint | ||
isolated_build = true | ||
skip_install = true |