Package: enforce-pep8
Enforce PEP-8Package allows to enforce certain kinds ofPEP-8convention coding styles (or perform overall code diagnostics).
It aims to help maintain programmers sanity while making any code changes.
In large object-oriented programs, it can sometimes be useful to put class definitions under control of a metaclass
that are used to alert programmers to potential problems.Most important that package enforces you to writeclearandconcise pythoniccode.ToolsProductionpython 3.6, 3.7, 3.8, 3.9Developmentpytestblackmypypylintflake8pydocstyleinterrogatecheck-manifesttravisUsageInstallationPlease run following script to obtain latest package from PYPI:pipinstallenforce-pep8
✨🍰✨Quick startBad class name: lowercase class name is definedfrompunish.styleimportAbstractStyleclassstylish(AbstractStyle):defname(self)->None:passTraceback(mostrecentcalllast):File"<stdin>",line1,in<module>punish.style.BadClassNameErrorClassname'stylish'specifiedinlowercase.Considertousecamelcasestyle!Bad attribute name: camelcase method name is definedfrompunish.styleimportAbstractStyleclassStylish(AbstractStyle):defshowName(self)->None:passTraceback(mostrecentcalllast):File"<stdin>",line1,in<module>punish.style.BadAttributeNameErrorBadattributenameisspecified:'Stylish:showName'.Considertouselowercasestyle:'Stylish:showname'!Bad method signature: method signature mismatch within base and child classesfrompunish.styleimportAbstractStyleclassStylish(AbstractStyle):defshow(self,indent:str=":")->str:passclassSoStylish(Stylish):defshow(self,indent:str=":",not_expected_argument:bool=False)->str:passTraceback(mostrecentcalllast):File"<stdin>",line1,in<module>punish.style.SignatureErrorSignaturemismatchin'SoStylish.show',(self,indent:str=':')->str!=(self,indent:str=':',not_expected_argument:bool=False)->strDuplicated attribute name: defined two methods with same namefrompunish.styleimportAbstractStyleclassStylish(AbstractStyle):defname(self)->None:passdefname(self)->None:passTraceback(mostrecentcalllast):File"<stdin>",line5,inStylishpunish.style.DuplicateAttributeError:'name'attributeisalreadydefinedin'Stylish'classBad argument type: not expected type is passed to the argumentfrompunish.typeimportOrderTypedMeta,String,TypedclassCar(metaclass=OrderTypedMeta):color:Typed=String()def__init__(self,color:str)->None:self.color=colorcar:Car=Car(color=23)Traceback(mostrecentcalllast):File"<stdin>",line5,in__init__TypeError:Expected'<class 'str'>'typefor'color'attributeBad setter type: not expected type for setter argumentfrompunish.typeimporttyped_propertyclassPerson:name:property=typed_property("name",str)age:property=typed_property("age",int)def__init__(self,name:str,age:int)->None:self._name=nameself._age=ageperson:Person=Person(name="Luke",age=22)person.age=NoneTraceback(mostrecentcalllast):File"<stdin>",line5,in__init__TypeError:'age'argumentmustbea'<class 'int'>'typeFrozen class attributes: it is forbidden to modify class attributesfrompunish.typeimportFrozenMetaclassBio(metaclass=FrozenMeta):name:str='Luke'company:str='Cisco'bio=Bio()bio.name='Amir'dataclasses.FrozenInstanceError:cannotassigntofield'name'Source codegitclonegit@github.com:vyahello/enforce-pep8.git
pipinstall-e.Or using direct source:pipinstallgit+https://github.com/vyahello/enforce-pep8@0.0.1⬆ back to topDevelopment notesTestingPlease execute command below to run unittests withpytesttool:pytestCIProject has Travis CI integration using.travis.ymlfile thus code analysis (black,pylint,flake8,mypy,pydocstyle) and unittests (pytest) will be run automatically after every made change to the repository.To be able to run code analysis, please execute command below:./analyse-source-code.shRelease notesPlease checkchangelogfile to get more details about actual versions and it's release notes.MetaAuthor –Volodymyr Yahello. Please checkauthorsfile for more details.Distributed under theMITlicense. SeeLICENSEfor more information.You can reach out me at:vyahello@gmail.comhttps://twitter.com/vyahellohttps://www.linkedin.com/in/volodymyr-yahello-821746127ContributingI would highly appreciate any contribution and support. If you are interested to add your ideas into project please follow next simple steps:Clone the repositoryConfiguregitfor the first time after cloning with yournameandemailpip install -r requirements.txtto install all project dependenciespip install -r requirements-dev.txtto install all development project dependenciesCreate your feature branch (git checkout -b feature/fooBar)Commit your changes (git commit -am 'Add some fooBar')Push to the branch (git push origin feature/fooBar)Create a new Pull RequestWhat's nextProject is inspired mainly bypythonicPEP8 code style reflected athttps://www.python.org/dev/peps/pep-0008.
Also decent ideas are described inhttps://github.com/zedr/clean-code-pythonproject.In general, future releases will contain API implementations from mentioned style guides above.All recent activities and ideas are described at projectissuespage.
If you have ideas you want to change/implement please do not hesitate and create an issue.⬆ back to top