diff --git a/.codeclimate.yml b/.codeclimate.yml index f1423473ac907469c359173d8a94543d9797fce8..fbc1ad6ff9e1533c1a9e22740a112b734318d667 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -14,9 +14,9 @@ engines: radon: enabled: true exclude_paths: -- examples/** -- tests/** -- docs/** + - examples/** + - tests/** + - docs/** ratings: paths: - - satella/** + - satella/** diff --git a/.travis.yml b/.travis.yml index c2b7c8e856fd8d1b740b872afd34c8100641b47e..10d38d2fa6fd3b59378c0b865374044ff5cd02f7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,17 @@ language: python python: - - "3.5" - - "3.6" - - "3.7-dev" - - "pypy3.5" + - "3.5" + - "3.6" + - "3.7-dev" + - "pypy3.5" cache: pip install: - - pip install -r requirements.txt - - pip install pyyaml toml - - pip install --force-reinstall "coverage>=4.0,<4.4" codeclimate-test-reporter # for codeclimate-test-reporter + - pip install -r requirements.txt + - pip install pyyaml toml + - pip install --force-reinstall "coverage>=4.0,<4.4" codeclimate-test-reporter # for codeclimate-test-reporter script: - - bash tests/test_posix/test_hang_until_sig.sh - - python setup.py nosetests + - bash tests/test_posix/test_hang_until_sig.sh + - python setup.py nosetests after_success: - - codeclimate-test-reporter - - bash build.sh + - codeclimate-test-reporter + - bash build.sh diff --git a/docs/conf.py b/docs/conf.py index 1cf4c7e4dfcaf61a38ae71fe8391264339950e28..11f335434f812627d1ba8ae237d8d778383f29c5 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -18,8 +18,8 @@ # import os import sys -sys.path.insert(0, os.path.abspath('..')) +sys.path.insert(0, os.path.abspath('..')) # -- General configuration ------------------------------------------------ diff --git a/docs/configuration/schema.rst b/docs/configuration/schema.rst index 30ca9306103f9d6418f0a80784a6d285b69cff44..201924bd8fe9b3f7c54f0c64c33d089853b8f21f 100644 --- a/docs/configuration/schema.rst +++ b/docs/configuration/schema.rst @@ -80,7 +80,7 @@ Lists you define as following { "type": "list", "of": { - .. descriptor type that this list has to have .. + ".. descriptor type that this list has to have .." } } @@ -91,9 +91,9 @@ Unions you define the following { "type": "union", "of": [ - .. descriptor type 1 .. - .. descriptor type 2 .. - ] + ".. descriptor type 1 ..", + ".. descriptor type 2 .." + ] } Dicts are more simple. Each key contains the key that should be present in the dict, and value is it's descriptor diff --git a/satella/coding/concurrent/thread.py b/satella/coding/concurrent/thread.py index 8c34fce6882eff5df3669c2536216eb81d329968..11637555abdafbefe9e3801083be1d18de39f07b 100644 --- a/satella/coding/concurrent/thread.py +++ b/satella/coding/concurrent/thread.py @@ -1,8 +1,7 @@ import ctypes import logging -import threading import platform - +import threading logger = logging.getLogger(__name__) diff --git a/satella/posix/__init__.py b/satella/posix/__init__.py index 88c5ed0588ee0f66d3ec4a5dd168f1895194155c..e12466b66d0455d668de0d7f31f77422b36e60b4 100644 --- a/satella/posix/__init__.py +++ b/satella/posix/__init__.py @@ -3,12 +3,12 @@ POSIX things """ import os +import typing as tp from .daemon import daemonize from .pidlock import AcquirePIDLock from .signals import hang_until_sig - __all__ = [ 'daemonize', 'AcquirePIDLock', @@ -18,7 +18,7 @@ __all__ = [ ] -def is_running_as_root(): +def is_running_as_root() -> bool: """ Is this process running as root? @@ -29,7 +29,7 @@ def is_running_as_root(): return os.geteuid() == 0 -def suicide(kill_entire_pg: bool = True): +def suicide(kill_entire_pg: bool = True) -> tp.NoReturn: """ Kill self. diff --git a/satella/posix/daemon.py b/satella/posix/daemon.py index 69d81a023390d2515c31d83597e59e23bc014588..9cd23d1ad11b5e138d30e0caf1ca6df5316e1d40 100644 --- a/satella/posix/daemon.py +++ b/satella/posix/daemon.py @@ -19,7 +19,6 @@ logger = logging.getLogger(__name__) DEVNULL = '/dev/null' - __all__ = ['daemonize'] diff --git a/setup.cfg b/setup.cfg index dc321ce6b880d3d1c316e6c65d2d00144602e513..bbd44019a1233bb1428e7a6d7e47d0fe819a2b5c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -11,7 +11,7 @@ description = Utilities for writing servers in Python url = https://github.com/piotrmaslanka/satella project-urls = Documentation = https://satella.readthedocs.io/ -classifier = +classifier = Programming Language :: Python Programming Language :: Python :: 3.5 Programming Language :: Python :: 3.6 @@ -25,12 +25,12 @@ classifier = Topic :: Software Development :: Libraries [pycodestyle] -max-line-length=80 +max-line-length = 80 [bdist_wheel] -universal=1 +universal = 1 [nosetests] -verbosity=3 -with-coverage=1 -detailed-errors=1 +verbosity = 3 +with-coverage = 1 +detailed-errors = 1 diff --git a/setup.py b/setup.py index ca783931a313f901ed1af56d5f47a99ac3450351..594a2324b2f220ec7e114e8a12973ab03370bd6d 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,6 @@ # coding=UTF-8 from setuptools import setup, find_packages + from satella import __version__ setup(keywords=['ha', 'high availability', 'scalable', 'scalability', 'server'], diff --git a/tests/test_coding/test_concurrent.py b/tests/test_coding/test_concurrent.py index bf85713dab934fe8a424531abcc453cbb84c540b..d3b967cfcab9d43d3b6072cf9f61f9b67d1df66b 100644 --- a/tests/test_coding/test_concurrent.py +++ b/tests/test_coding/test_concurrent.py @@ -1,8 +1,9 @@ # coding=UTF-8 from __future__ import print_function, absolute_import, division -import unittest -import time + import platform +import time +import unittest from satella.coding.concurrent import TerminableThread, CallableGroup @@ -20,7 +21,6 @@ class TestCallableGroup(unittest.TestCase): @unittest.skipIf(platform.python_implementation() == 'PyPy', 'force=True doesn''t work on PyPy') def test_terminable_thread_force(self): - class MyTerminableThread(TerminableThread): def run(self): a = 0 @@ -47,7 +47,6 @@ class TestCallableGroup(unittest.TestCase): self.assertIsInstance(cg()[0], NameError) def test_callable_group(self): - a = { 'a': False, 'b': False @@ -63,4 +62,3 @@ class TestCallableGroup(unittest.TestCase): cg() self.assertTrue(all(a.values())) - diff --git a/tests/test_coding/test_fun_static.py b/tests/test_coding/test_fun_static.py index c3bd9e7dd5759a46885745512315f1a228ce545a..fe95595baa32108a8eb12921090bf23f18f6426d 100644 --- a/tests/test_coding/test_fun_static.py +++ b/tests/test_coding/test_fun_static.py @@ -1,7 +1,4 @@ import unittest -from threading import Thread -from time import sleep -from queue import Queue from satella.coding import static_var diff --git a/tests/test_coding/test_locked_dataset.py b/tests/test_coding/test_locked_dataset.py index 1bb1c4d6fc8c469269da8538d416e8d5c08e7c75..d4e64e4e2808018ba454aaa2247e795abf60a8fa 100644 --- a/tests/test_coding/test_locked_dataset.py +++ b/tests/test_coding/test_locked_dataset.py @@ -26,4 +26,4 @@ class TestLockedDataset(unittest.TestCase): with a: self.assertEquals(a.counter, 1) - self.assertRaises(ResourceNotLocked, lambda: a.counter) \ No newline at end of file + self.assertRaises(ResourceNotLocked, lambda: a.counter) diff --git a/tests/test_coding/test_monitor.py b/tests/test_coding/test_monitor.py index ea8dbe18811989b9c43760fbd916f3cdbdae868f..b27934a489becd4807b222c0c67e411e5826c819 100644 --- a/tests/test_coding/test_monitor.py +++ b/tests/test_coding/test_monitor.py @@ -1,9 +1,8 @@ import unittest +from queue import Queue from threading import Thread from time import sleep -from queue import Queue - from satella.coding import Monitor diff --git a/tests/test_coding/test_rethrow.py b/tests/test_coding/test_rethrow.py index 6784e060b22837e76c495582908f4236bee51a2f..d7753be647b539d90156e3b822c502882ea563ba 100644 --- a/tests/test_coding/test_rethrow.py +++ b/tests/test_coding/test_rethrow.py @@ -1,6 +1,8 @@ # coding=UTF-8 from __future__ import print_function, absolute_import, division + import unittest + from satella.coding import rethrow_as, silence_excs @@ -43,6 +45,7 @@ class TestStuff(unittest.TestCase): def test_issue_10(self): class WTFException1(Exception): pass + class WTFException2(Exception): pass @rethrow_as((NameError, WTFException1), @@ -55,7 +58,7 @@ class TestStuff(unittest.TestCase): def test_issue_14a(self): - @rethrow_as(*(((NameError, ValueError), TypeError), )) + @rethrow_as(*(((NameError, ValueError), TypeError),)) def ro(p): raise p() diff --git a/tests/test_coding/test_structures.py b/tests/test_coding/test_structures.py index 703692689d014fa7e258b08b2406c00e3d0ffb40..969072cdefbe1320bb8490177cf513bad821a312 100644 --- a/tests/test_coding/test_structures.py +++ b/tests/test_coding/test_structures.py @@ -6,9 +6,9 @@ import unittest import mock +from satella.coding.concurrent import CallableGroup from satella.coding.structures import TimeBasedHeap, Heap, typednamedtuple, \ OmniHashableMixin, DictObject, apply_dict_object -from satella.coding.concurrent import CallableGroup class TestCallableGroup(unittest.TestCase): diff --git a/tests/test_configuration/test_sources/test_envvars.py b/tests/test_configuration/test_sources/test_envvars.py index d6b6b98fb5f5b82742db931debe9b882345c25c7..66a22444a4b021c78ec926473afbb6681c64b52b 100644 --- a/tests/test_configuration/test_sources/test_envvars.py +++ b/tests/test_configuration/test_sources/test_envvars.py @@ -24,4 +24,4 @@ class TestEnvVarsSource(SourceTestCase): EnvironmentSource('test', 'test'), on_fail=MergingSource.SILENT ) - self.assertEquals(ds.provide(), {}) \ No newline at end of file + self.assertEquals(ds.provide(), {}) diff --git a/tests/test_configuration/test_sources/utils.py b/tests/test_configuration/test_sources/utils.py index 83a36f572f483fd214883cd8386c0bb343b60e0d..f6b130ec1ef6438fc05f66a74ae28732002eeddd 100644 --- a/tests/test_configuration/test_sources/utils.py +++ b/tests/test_configuration/test_sources/utils.py @@ -1,7 +1,7 @@ import functools import os -import unittest import typing as tp +import unittest from satella.configuration.sources import BaseSource from satella.exceptions import ConfigurationError diff --git a/tests/test_exception_handling/test_dump_frames_on.py b/tests/test_exception_handling/test_dump_frames_on.py index 6e8a15315ff1453323e85ac880e4a77d25867aa1..921338a93eb034f0fbcc0b3c81539f9647878831 100644 --- a/tests/test_exception_handling/test_dump_frames_on.py +++ b/tests/test_exception_handling/test_dump_frames_on.py @@ -1,10 +1,9 @@ import logging -import typing as tp -import unittest -import os -import signal import sys +import unittest + from satella.instrumentation.dump_frames_on import dump_frames_on + logger = logging.getLogger(__name__) diff --git a/tests/test_exception_handling/test_dump_to_file.py b/tests/test_exception_handling/test_dump_to_file.py index 728953a68c996c5406d968b20b007391e3686689..604211e372ebe3531ddf43ceb2cdcf0eca86999f 100644 --- a/tests/test_exception_handling/test_dump_to_file.py +++ b/tests/test_exception_handling/test_dump_to_file.py @@ -23,7 +23,7 @@ class TestDumpToFile(ExceptionHandlingTestCase): def test_dump_to_file(self): try: def makeexc(): - print(hello) # raises NameError + print(hello) # raises NameError self.make_exception(makeexc) diff --git a/tests/test_instrumentation/test_metrics.py b/tests/test_instrumentation/test_metrics.py index f62011f5e8a51408c182c1dc642a6c440f379ba4..b9bb067a1c828fed2c1f2611ff93e4ee7610aaa1 100644 --- a/tests/test_instrumentation/test_metrics.py +++ b/tests/test_instrumentation/test_metrics.py @@ -1,6 +1,6 @@ -import unittest import time -import typing as tp +import unittest + from satella.instrumentation.metrics import getMetric, DEBUG, RUNTIME, INHERIT @@ -83,4 +83,3 @@ class TestMetric(unittest.TestCase): self.assertEquals(metric.to_json(), [2, 2]) time.sleep(1.2) self.assertEquals(metric.to_json(), [0, 2]) - diff --git a/tests/test_json.py b/tests/test_json.py index 19f4782031d411268e169f784589d802302262c2..e5dd90c13b5b2c996aa29025674a1efd361c6c38 100644 --- a/tests/test_json.py +++ b/tests/test_json.py @@ -1,12 +1,12 @@ -import unittest import typing as tp +import unittest + from satella.json import JSONAble, json_encode class TestJson(unittest.TestCase): def test_jsonable_objects(self): - class MyClass(JSONAble): def to_json(self) -> tp.Union[list, dict, str, int, float, None]: return [] diff --git a/tests/test_posix/test_suicide.py b/tests/test_posix/test_suicide.py index a7354ca35960379161268228494cc8eb0377da12..580dfee9bb1cc8059de73806883442c050e2e589 100644 --- a/tests/test_posix/test_suicide.py +++ b/tests/test_posix/test_suicide.py @@ -2,10 +2,10 @@ from __future__ import print_function, absolute_import, division import os +import sys import unittest from satella.posix import suicide -import sys class TestSuicide(unittest.TestCase):