Only allow `as` for internal modules

So we have an internal code style rule that as is not allowed for external modules.
As an example the following is disallowed:

import matplotlib.pyplot as plt

But it is allowed for modules in a given project.
Is there a way to setup such a rule with Flake8?
We want such that on precommit hook it will fail if the rule is not uphold due to the fact that some developers does not uphold the rule.

  • 1

    i dont think flake can do this but you might be able to use the AST module to look at the files for this

    – 

  • you could write your own flake8 plugin for this — but I don’t think any existing tool would enforce this inane style

    – 

Leave a Comment