diff --git a/README.md b/README.md index 7e965e8dfc2abd09b8222616a80a86375d780380..41f6ee6323594dce052ed561c665bdad31272b12 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ satella ======== -[](https://codeclimate.com/github/piotrmaslanka/satella) +[](https://codeclimate.com/github/piotrmaslanka/satella) [](https://codeclimate.com/github/piotrmaslanka/satella) [](https://pypi.python.org/pypi/satella) [](https://badge.fury.io/py/satella) @@ -18,7 +18,9 @@ Satella uses [semantic versioning 2.0](https://semver.org/spec/v2.0.0.html). Satella contains, among other things: -* things to help you manage your [application's configuration](satella/configuration) +* things to help you manage your [application's configuration](satella/configuration) that allows + you to both load a configuration and specify it's schema using only + Python dictionaries * a fully equipped [metrics library](satella/instrumentation/metrics) * alongside a fully metricized [ThreadPoolExecutor](satella/instrumentation/metrics/structures/threadpool.py) * and an exporter to [Prometheus](satella/instrumentation/metrics/exporters/prometheus.py) or really any @@ -29,7 +31,8 @@ Satella contains, among other things: * [FastAPI](https://github.com/Dronehub/fastapi-satella-metrics) * [Django](https://github.com/piotrmaslanka/django-satella-metrics) * [Flask](https://github.com/piotrmaslanka/flask-satella-metrics) -* helpful [exception handlers](satella/exception_handling) +* helpful [exception handlers](satella/exception_handling) as well as capacity to dump all stack frames + along with their local variables for each thread * monitoring [CPU usage](satella/instrumentation/cpu_time/collectors) on the system and by your own process * common programming [idioms and structures](satella/coding) diff --git a/satella/cassandra/common.py b/satella/cassandra/common.py index 448f63edaf5cd05c0fe0c891fbb398b4511e4593..acb3224d0c8a64a02b262899685601f66984efe1 100644 --- a/satella/cassandra/common.py +++ b/satella/cassandra/common.py @@ -1,5 +1,5 @@ try: from cassandra.cluster import ResponseFuture except ImportError: - class ResponseFuture: + class ResponseFuture: # pylint: disable=too-few-public-methods pass diff --git a/satella/coding/expect_exception.py b/satella/coding/expect_exception.py index 0caea5e798ca7a73b1bee59aba571b5d1943f293..d54ea94841b6a5e7664a81168d1d4eb9a4892011 100644 --- a/satella/coding/expect_exception.py +++ b/satella/coding/expect_exception.py @@ -34,8 +34,7 @@ class expect_exception: def __exit__(self, exc_type, exc_val, exc_tb): if exc_type is None: - raise self.else_raise(*self.else_raise_args, - **self.else_raise_kwargs) + raise self.else_raise(*self.else_raise_args, **self.else_raise_kwargs) elif not isinstance(exc_val, self.exc_to_except): return False return True diff --git a/satella/coding/misc.py b/satella/coding/misc.py index 05962dbf19b97f9767aa52f9644d83bde28a545f..1152e5e1fc369d2c23277bde603f03ea071f1cc2 100644 --- a/satella/coding/misc.py +++ b/satella/coding/misc.py @@ -62,7 +62,7 @@ def contains(needle, haystack) -> bool: class Closeable: """ - A class that needs to clean up it's own resources. + A class that needs to clean up its own resources. It's destructor calls .close(). Use like this: @@ -254,8 +254,7 @@ def update_key_if_true(dictionary: tp.Dict, key: tp.Hashable, value: tp.Any, return dictionary -def get_arguments(function: tp.Callable, *args, **kwargs) -> \ - tp.Dict[str, tp.Any]: +def get_arguments(function: tp.Callable, *args, **kwargs) -> tp.Dict[str, tp.Any]: """ Return local variables that would be defined for given function if called with provided arguments. @@ -273,6 +272,7 @@ def get_arguments(function: tp.Callable, *args, **kwargs) -> \ return _get_arguments(function, False, *args, **kwargs) +# pylint: disable=too-many-locals @rethrow_as(IndexError, TypeError) def _get_arguments(function: tp.Callable, special_behaviour: bool, *args, **kwargs): """ @@ -283,9 +283,7 @@ def _get_arguments(function: tp.Callable, special_behaviour: bool, *args, **kwar local_vars = {} positionals = [param for param in reversed(params) if - param.kind in (Parameter.POSITIONAL_OR_KEYWORD, - Parameter.POSITIONAL_ONLY, - Parameter.VAR_POSITIONAL)] + param.kind in (Parameter.POSITIONAL_OR_KEYWORD, Parameter.POSITIONAL_ONLY, Parameter.VAR_POSITIONAL)] args = list(reversed(args)) arguments_left = set(param.name for param in params) @@ -303,8 +301,7 @@ def _get_arguments(function: tp.Callable, special_behaviour: bool, *args, **kwar try: if arg.default != Parameter.empty: raise AttributeError() - else: - break + break except (AttributeError, TypeError): v = arg.default local_vars[arg_name] = v @@ -368,8 +365,7 @@ def call_with_arguments(function: tp.Callable, arguments: tp.Dict[str, tp.Any]) continue elif param.default == Parameter.empty: raise TypeError('Argument %s not found' % (param_name,)) - else: - continue + continue if param_kind == Parameter.POSITIONAL_ONLY or param_kind == Parameter.POSITIONAL_OR_KEYWORD: args.append(arguments.pop(param_name)) diff --git a/satella/coding/recast_exceptions.py b/satella/coding/recast_exceptions.py index 3b105ba2d4e066947761887cbc4daf8fe6959a7a..6c1e6e9b5875853008dc3a43200fa972575fc180 100644 --- a/satella/coding/recast_exceptions.py +++ b/satella/coding/recast_exceptions.py @@ -263,8 +263,7 @@ class rethrow_as: elif self.returns_factory is not None: return self.returns_factory() return - else: - return v + return v return inner @@ -279,8 +278,7 @@ class rethrow_as: self.__exception_remapped.was_raised = True if to is None: return True - else: - raise to(self.exception_preprocessor(exc_val)) + raise to(self.exception_preprocessor(exc_val)) def raises_exception(exc_class: tp.Union[ExceptionClassType, tp.Tuple[ExceptionClassType, ...]],