Skip to main content

Various cli tools related to MRO. Useful for debugging complex class strictures.

Project description

https://badge.fury.io/py/mro-tools.png

Various cli tools related to MRO. Useful for debugging complex class strictures.

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.3.0 (2019-02-08)

  • Added --no-color option. This allows open in other editors for syntax highlight: mro-tools klass ... | vim -R - +'set syntax=python'

  • Added file to class header in klass command

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

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

mro-tools-0.3.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

mro_tools-0.3.0-py2.py3-none-any.whl (8.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file mro-tools-0.3.0.tar.gz.

File metadata

  • Download URL: mro-tools-0.3.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.7

File hashes

Hashes for mro-tools-0.3.0.tar.gz
Algorithm Hash digest
SHA256 7fbb57d9f5980f15f90e9c074c2822618bfe2b59037b522762bf23df2566f898
MD5 417c2cdcd28ff207d63c991105a07fab
BLAKE2b-256 1e0ba24ca69177f7ee5bde58d3e464cdd6e12ab13ad88c1fb339f47e8aa47cf9

See more details on using hashes here.

File details

Details for the file mro_tools-0.3.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for mro_tools-0.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 3ebaacc6fdc97ba0c8ee75f591c8e1932c4d97a63208a1ce1497577f863ace96
MD5 08ca34fe1d0d0c54a89507783739031e
BLAKE2b-256 76d156bc59ee2b982093bb58b0ebd52fa3c392aa989e8c79c770ac2278f9db46

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page