Various cli tools related to MRO. Useful for debugging complex class strictures.
Project description
Various cli tools related to MRO. Useful for debugging complex class strictures.
Free software: MIT license
Installing
You can install mro-tools using pip:
$ pip install mro-tools
Why?
Inheritance is wonderful. Except when its not. How many times did you have to debug a complex class with MRO of >30 classes? You will then know its not pleasant. Editors don’t help much since as soon you jump to a base class, all editor inheritance calculations are relative to the jumped class, not the original subclass. That makes it non-trivial to see what actually happens within code execution without dropping into pdb. This package aims to aid with such issues. It has a collection of cli tools which help troubleshooting complex classes with big MRO trees.
Using
MRO tools exposes all tools via a single group command. All available commands can be seen by executing mro-tools command:
❯❯❯ mro-tools Usage: mro-tools [OPTIONS] COMMAND [ARGS]... Options: --help Show this message and exit. Commands: method Get all method definitions within all classes... version Print version of mro-tools
Each sub-command has more documentation:
❯❯❯ mro-tools version --help Usage: mro-tools version [OPTIONS] Print version of mro-tools Options: --help Show this message and exit.
mro-tools can also be accessed as a Python module:
❯❯❯ python -m mro_tools
Examples
❯❯❯ python -m mro_tools method django.views.generic:FormView.get_context_data ======== Full MRO ======== django.views.generic.edit.FormView django.views.generic.base.TemplateResponseMixin django.views.generic.edit.BaseFormView django.views.generic.edit.FormMixin django.views.generic.base.ContextMixin django.views.generic.edit.ProcessFormView django.views.generic.base.View builtins.object ---------------------------------------------------- django.views.generic.edit.FormMixin.get_context_data ---------------------------------------------------- def get_context_data(self, **kwargs): """Insert the form into the context dict.""" if 'form' not in kwargs: kwargs['form'] = self.get_form() return super().get_context_data(**kwargs) ------------------------------------------------------- django.views.generic.base.ContextMixin.get_context_data ------------------------------------------------------- def get_context_data(self, **kwargs): if 'view' not in kwargs: kwargs['view'] = self if self.extra_context is not None: kwargs.update(self.extra_context) return kwargs
History
0.2.0 (2018-09-22)
Added klass command
0.1.3 (2018-09-13)
Added pygments code highlight to method
0.1.2 (2018-02-13)
Added --django-configurations option
0.1.1 (2018-01-05)
Fixes RST markup in README
0.1.0 (2018-01-05)
First release on PyPI.
Credits
Development Lead
Miroslav Shubernetskiy - https://github.com/miki725
Contributors
None yet. Why not be the first?
License
The MIT License (MIT)
Copyright (c) 2018, Miroslav Shubernetskiy
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for mro_tools-0.2.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c7ba489374ea75300521004bcef6d1a5d8f39e76710ce1d23a2e84476c16a63 |
|
MD5 | 3ad0dd9fb8a66688b771bf742552d304 |
|
BLAKE2b-256 | 02f3e7e223a18b561439a882230bd85de115fe59c021d6ccc8f995a879b35ab6 |