Skip to main content

Pyeo is an advanced static analysis tool tailored specifically to enforce the principles advocated by Elegant Objects (elegantobjects.org) in Python projects. It serves as a quality control instrument to ensure that your Python code adheres to the core tenets of elegance, simplicity, and maintainability.

Project description

pyeo

wemake-python-styleguide

Pyeo is an advanced static analysis tool tailored specifically to enforce the principles advocated by Elegant Objects (elegantobjects.org) in Python projects. It serves as a quality control instrument to ensure that your Python code adheres to the core tenets of elegance, simplicity, and maintainability.

pip install eo-styleguide

Simple example of usage:

from typing import Protocol, final

import attrs
from pyeo import elegant


class House(Protocol):
    def area(self) -> int: ...


@elegant
@final
@attrs.define(frozen=True)
class HttpHouse(House):

    def area(self) -> int:
        return 10

Mypy helps prevent AttributeError and other type-related errors by providing static type checking for Python code. It allows specifying variable types, function arguments, and return types to catch potential type issues before the program runs. By using Mypy, developers can identify and fix problems related to attribute access and other type mismatches, leading to improved code quality and easier maintenance.

  • No code in constructors (why?)

  • No getters and setters (why?)

  • No mutable objects (why?)

attrs.define(frozen=True) is a parameter used in the attrs library to create classes with attributes that cannot be modified after the instance is created (i.e., immutable or "frozen" classes). The attrs library allows defining classes using the @attr.s decorator or by explicitly calling the attr.define function, and frozen=True is one of the parameters for specifying attribute behavior in the class. When you use attrs.define(frozen=True) for a class, all its attributes become read-only after the instance is created, making the class "frozen" or "immutable," preventing any changes to its attribute values.

  • No readers, parsers, controllers, sorters, and so on (why?)

  • No static methods, not even private ones (why?)

  • No instanceof, type casting, or reflection (why?)

  • No public methods without a contract (interface) (why?)

  • No statements in test methods except assert (why?)

  • No ORM or ActiveRecord (why? and why?)

Detect using ORM or ActiveRecord tools on project by design/code review

  • No implementation inheritance (why? and why?)

Each @elegant object must be typing.final

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

eo_styleguide-0.0.1a3.tar.gz (7.6 kB view hashes)

Uploaded Source

Built Distribution

eo_styleguide-0.0.1a3-py3-none-any.whl (18.9 kB view hashes)

Uploaded Python 3

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