Skip to main content

Check code for newspaper style

Project description

Enforce Newspaper Style with Flake

Motivation

Good code reads like a newspaper. Start with the highest abstraction, go to the details. This also enables to read the code without an editor.

Quoting Robert C. Martin from his Clean Code book.

“Think of a well-written newspaper article. You read it vertically. At the top you expect a headline that will tell you what the story is about and allows you to decide whether it is something you want to read. The first paragraph gives you a synopsis of the whole story, hiding all the details while giving you the broad-brush concepts. As you continue downward, the details increase until you have all the dates, names, quotes, claims, and other minutia.”

In Python newspaper code should look like this.

def headline():
    text()

def text():  # this needs to be defined after the usage.
    ...

There hasn't been an automatic way in python to check for this. So here it is.

Usage

# install the flake8 extension for newspaper style
pip3 install flake8-newspaper-style==0.4.2
# then check your code
flake8 --select=NEW src  # here it restricts flake8 to newspaper style issues

References

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

flake8-newspaper-style-0.4.3.tar.gz (4.5 kB view details)

Uploaded Source

File details

Details for the file flake8-newspaper-style-0.4.3.tar.gz.

File metadata

File hashes

Hashes for flake8-newspaper-style-0.4.3.tar.gz
Algorithm Hash digest
SHA256 d05924256cb9992eb61d3718c7301bc8f3b2a847f159b5f9e25a508261359974
MD5 8baa2dfcee79af1ca6448736955471f7
BLAKE2b-256 2b3fc43be62fb54b5b1d22954aceeefe9bf1a7238d9b6f36d811ed6f363067af

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