<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Hassan Farid</title>
    <description>The latest articles on DEV Community by Hassan Farid (@hassanfarid).</description>
    <link>https://dev.to/hassanfarid</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F135380%2Fa23181ea-1af5-4eed-9453-552eb75b5d95.jpeg</url>
      <title>DEV Community: Hassan Farid</title>
      <link>https://dev.to/hassanfarid</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hassanfarid"/>
    <language>en</language>
    <item>
      <title>Productivity wings for Python Project</title>
      <dc:creator>Hassan Farid</dc:creator>
      <pubDate>Fri, 24 Apr 2020 01:08:12 +0000</pubDate>
      <link>https://dev.to/hassanfarid/productivity-wings-for-python-project-4alg</link>
      <guid>https://dev.to/hassanfarid/productivity-wings-for-python-project-4alg</guid>
      <description>&lt;h2&gt;
  
  
  Python - Template Project (Part - 1)
&lt;/h2&gt;

&lt;p&gt;Source:&lt;br&gt;
&lt;a href="https://github.com/hassanfarid/python-template"&gt;https://github.com/hassanfarid/python-template&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;Different studies suggest that code (a piece of functionality) is read many more times than written or updated. Which highlights the importance of writing good quality code by following consistent code style and documentation style guides. Writing tests for the code piece improves readability of the code, and as well as improves stability of code base.&lt;/p&gt;

&lt;p&gt;The knowledge about importance of writing quality code is common knowledge and agreed upon by everyone.&lt;/p&gt;

&lt;p&gt;This project attempts to provide a template project, which can be used to get on-board with all known good practices using industry standard toolset for new and existing projects.&lt;/p&gt;
&lt;h2&gt;
  
  
  How to structure your code base
&lt;/h2&gt;

&lt;p&gt;This maybe a subjective matter, and there' no single bullet for this. Here are my recommendations for hot to structure your source code,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;| component-code-repository (example: fantastic-app-backend)
    | ci/ # all scripts helpful for CI process
    | scripts/ # all short hand scripts for testing and running application in local env
    | src/ # may contain all the source code specific to this repository
    | tests/ # contains test suite for your code base
    | CODEOWNERS
    | CONTRIBUTION.md
    | Dockerfile
    | docker-compose.yml
    | README.md
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  How to Build your project?
&lt;/h2&gt;

&lt;p&gt;The project can be built for multiple targets using single Dockerfile. The purpose of single Dockerfile is to make maintenance of deployment code easier.&lt;/p&gt;

&lt;p&gt;This project can be built as docker image with all the targets supported by Dockerfile,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ci - for using target image in continuous integration process&lt;/li&gt;
&lt;li&gt;prod - for publishing target image in production
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# You can set the target to either `ci` or `prod` based intention&lt;/span&gt;
&lt;span class="nv"&gt;TARGET&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'ci'&lt;/span&gt;

&lt;span class="c"&gt;# Build image for $TARGET environment&lt;/span&gt;
docker build &lt;span class="nt"&gt;--build-arg&lt;/span&gt; &lt;span class="nv"&gt;TARGET&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$TARGET&lt;/span&gt; &lt;span class="nt"&gt;-t&lt;/span&gt; python-template:&lt;span class="nv"&gt;$TARGET&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; Dockerfile &lt;span class="nb"&gt;.&lt;/span&gt;

&lt;span class="c"&gt;# The output image will be labelled `python-template:ci` or `python-template:prod`&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Features for Continuous Integration
&lt;/h2&gt;

&lt;p&gt;The project has provided templates for ensuring best practices and maintaining stability of code base. The following features are supported,&lt;/p&gt;

&lt;h3&gt;
  
  
  Coding Guidelines
&lt;/h3&gt;

&lt;p&gt;Specific instructions about &lt;a href="//CONTRIBUTING.md"&gt;coding guidelines&lt;/a&gt; are documented separately.&lt;/p&gt;

&lt;p&gt;The integrated tools help python projects maintain coding standards including,&lt;/p&gt;

&lt;h4&gt;
  
  
  Coding Style Guide
&lt;/h4&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# This test will use pycodestyle to validate against PEP-8 standards&lt;/span&gt;
docker run &lt;span class="nt"&gt;--rm&lt;/span&gt; python-template:ci bash ../ci/pycodestyle/script.sh

&lt;span class="c"&gt;# This test will use pydocstyle to validate against PEP-257 standards&lt;/span&gt;
docker run &lt;span class="nt"&gt;--rm&lt;/span&gt; python-template:ci bash ../ci/pydocstyle/script.sh

&lt;span class="c"&gt;# This test will use mypy to validate against PEP-484 standards&lt;/span&gt;
docker run &lt;span class="nt"&gt;--rm&lt;/span&gt; python-template:ci bash ../ci/mypy/script.sh

&lt;span class="c"&gt;# as an alternate pylint may also be used code advanced coding guidelines specific to your project&lt;/span&gt;
&lt;span class="c"&gt;# Note: to make it work as expected, you need to configure pylint configurations as desired&lt;/span&gt;
&lt;span class="c"&gt;# This test will use pylint to validate PEP-8, PEP-257, and others&lt;/span&gt;
docker run &lt;span class="nt"&gt;--rm&lt;/span&gt; python-template:ci bash ../ci/pylint/script.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Code Stability Test
&lt;/h4&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# This test will use pytest to run all test suits defined in project&lt;/span&gt;
&lt;span class="c"&gt;# additionaly: this also geenrates test coverage report on console&lt;/span&gt;
docker run &lt;span class="nt"&gt;--rm&lt;/span&gt; python-template:ci bash ../ci/pytest/script.sh

&lt;span class="c"&gt;# This will use coverage tool to generate test coverage, and run test if coverage is not generated yet&lt;/span&gt;
&lt;span class="c"&gt;# the coverage html report is generated at ./cov_html as configured in ../ci/coverage/.coveragerc.ini&lt;/span&gt;
docker run &lt;span class="nt"&gt;--rm&lt;/span&gt; python-template:ci bash ../ci/coverage/script.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Code Documentation
&lt;/h4&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# This script will generate code documentation using code comments&lt;/span&gt;
&lt;span class="c"&gt;# the output html is generated in ../docs/_build/html&lt;/span&gt;
docker run &lt;span class="nt"&gt;--rm&lt;/span&gt; python-template:ci bash ../ci/generate_code_documentation.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;






&lt;p&gt;Source:&lt;br&gt;
&lt;a href="https://github.com/hassanfarid/python-template"&gt;https://github.com/hassanfarid/python-template&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You are welcome to contribute to this starter template by,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;leaving a comment&lt;/li&gt;
&lt;li&gt;open an issue on Github&lt;/li&gt;
&lt;li&gt;submit a pull request on Github&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>template</category>
      <category>python</category>
      <category>gettingstarted</category>
    </item>
  </channel>
</rss>
