From 3a96a4f56942cef570605ca017894a4de1eb8c08 Mon Sep 17 00:00:00 2001
From: dboe <dboe@ipp.mpg.de>
Date: Sun, 11 Oct 2020 15:35:41 +0200
Subject: [PATCH] Update template

---
 LICENSE.rst                    |  1 -
 Makefile                       |  3 +-
 docs/apidoc-template/toc.rst_t |  1 -
 docs/usage.rst                 |  2 +-
 setup.cfg                      | 13 +++++----
 setup.py                       |  2 +-
 tests/test_package.py          |  5 ++--
 tfields/__main__.py            | 53 ++++++++++++++++++++++------------
 8 files changed, 48 insertions(+), 32 deletions(-)

diff --git a/LICENSE.rst b/LICENSE.rst
index d3b5c40..fbeca6d 100644
--- a/LICENSE.rst
+++ b/LICENSE.rst
@@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 SOFTWARE.
-
diff --git a/Makefile b/Makefile
index 7147b30..5bd7f7e 100644
--- a/Makefile
+++ b/Makefile
@@ -12,7 +12,8 @@ GITSTATUS = $(shell git status --porcelain)
 part ?= patch
 
 test: FORCE
-	flake8 rna tests
+	flake8 tfields tests
+	pylint tfields tests
 	py.test
 
 coverage:
diff --git a/docs/apidoc-template/toc.rst_t b/docs/apidoc-template/toc.rst_t
index 6498a38..8d0b852 100644
--- a/docs/apidoc-template/toc.rst_t
+++ b/docs/apidoc-template/toc.rst_t
@@ -8,4 +8,3 @@ API Documentation
 {% for docname in docnames %}
    {{ docname }}
 {%- endfor %}
-
diff --git a/docs/usage.rst b/docs/usage.rst
index 976b181..c0d9b77 100644
--- a/docs/usage.rst
+++ b/docs/usage.rst
@@ -4,4 +4,4 @@ Usage
 
 To use tfields in a project::
 
-    >>> import tfields
\ No newline at end of file
+    >>> import tfields
diff --git a/setup.cfg b/setup.cfg
index b990edb..9bf0792 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -13,7 +13,7 @@ search = version='{current_version}'
 replace = {new_version}
 
 [bumpversion:file:docs/cookiecutter_input.json]
-search = "package_version": "{current_version}"
+search = 'package_version': '{current_version}'
 replace = {new_version}
 
 [metadata]
@@ -71,6 +71,7 @@ docs =
     sphinx_rtd_theme>=0.4.3
 test =
     flake8
+    pylint
     pytest
     pytest-cov
     coverage
@@ -88,14 +89,14 @@ exclude_lines =
     pragma: no cover
     if False
 
-[coverage:run]
-omit = 
-    tfields/plotting/*.py
-
 [flake8]
 max-line-length = 99
 doctests = True
 exclude = .git, .eggs, __pycache__, docs, dist, venv, .tox
+ignore = E203 W503 W504  # wrong flake defaults: see https://github.com/psf/black/issues/315, https://github.com/psf/black/issues/43
+
+[pylint.]
+ignore = setup.py
 
 [build_sphinx]
 builder = html,man
@@ -113,6 +114,7 @@ skip_missing_interpreters = true
 envlist = 
 	py{35,36,37,38}
 recreate = true
+usedevelop = true
 
 [gh-actions]
 python = 
@@ -131,7 +133,6 @@ commands =
 	pytest \
 	--cov={[metadata]name} \
 	--ignore=docs \
-	--ignore=tfields/plotting \
 	--junitxml=report/junit.xml
 
 [testenv:flake8]
diff --git a/setup.py b/setup.py
index 55b3dc0..76d623e 100644
--- a/setup.py
+++ b/setup.py
@@ -1,3 +1,3 @@
 from setuptools import setup
 
-setup(version='0.3.2')
+setup(version="0.3.2")
diff --git a/tests/test_package.py b/tests/test_package.py
index 9f5366e..d198d12 100644
--- a/tests/test_package.py
+++ b/tests/test_package.py
@@ -3,9 +3,10 @@
 """Tests for `tfields` package."""
 
 import unittest
+import tfields
 
 
-class Test_tfields(unittest.TestCase):
+class TestPackage(unittest.TestCase):
     """Tests for `tfields` package."""
 
     def setUp(self):
@@ -16,5 +17,5 @@ class Test_tfields(unittest.TestCase):
 
     def test_version_type(self):
         """Assure that version type is str."""
-        import tfields
+
         self.assertIsInstance(tfields.__version__, str)
diff --git a/tfields/__main__.py b/tfields/__main__.py
index d9d053b..69d2eba 100644
--- a/tfields/__main__.py
+++ b/tfields/__main__.py
@@ -8,49 +8,64 @@ import tfields
 
 
 class SomeAction(argparse.Action):
+    """Some actions."""
+
     def __init__(self, option_strings, dest, nargs=None, **kwargs):
         if nargs is not None:
             raise ValueError("nargs not allowed")
         super().__init__(option_strings, dest, **kwargs)
 
     def __call__(self, parser, namespace, values, option_string=None):
-        print("Example action invoked by manage in namespace: %r with values %r"
-              " and option string %r" % (namespace, values, option_string))
+        print(
+            "Example action invoked by manage in namespace: %r with values %r"
+            " and option string %r" % (namespace, values, option_string)
+        )
         setattr(namespace, self.dest, values)
 
+    def showcase_dummy(self):
+        """
+        You can define a method to expose functionality of the class
+        """
+        print(self)
+
 
-def manage(args):
+def manage(args_):
+    """Example function."""
     print("Managing!")
-    print(args.x * args.y)
+    print(args_.x * args_.y)
 
 
-def parse_args(args):
+def parse_args(args_):
+    """Parse args."""
     # create the top-level parser
-    parser = argparse.ArgumentParser(prog='tfields app')
-    parser.add_argument('--version', action='version',
-                        version='v' + tfields.__version__,
-                        help="Show program's version number and exit")
-    parser = argparse.ArgumentParser(prog='tfields app')
+    parser = argparse.ArgumentParser(prog="tfields app")
+    parser.add_argument(
+        "--version",
+        action="version",
+        version="v" + tfields.__version__,
+        help="Show program's version number and exit",
+    )
+    parser = argparse.ArgumentParser(prog="tfields app")
 
     # subparsers
-    subparsers = parser.add_subparsers(help='sub-command help')
+    subparsers = parser.add_subparsers(help="sub-command help")
 
     # create the parser for the "test" command
-    example_sub_parser = subparsers.add_parser('manage', help='manage something')
-    example_sub_parser.add_argument('-x', type=int, default=1)
-    example_sub_parser.add_argument('-y', type=float, default=42.)
+    example_sub_parser = subparsers.add_parser("manage", help="manage something")
+    example_sub_parser.add_argument("-x", type=int, default=1)
+    example_sub_parser.add_argument("-y", type=float, default=42.0)
     example_sub_parser.set_defaults(func=manage)
 
     # If no arguments were used, print base-level help with possible commands.
-    if len(args) == 0:
+    if len(args_) == 0:
         parser.print_help(file=sys.stderr)
         sys.exit(1)
 
-    args = parser.parse_args(args)
+    args_ = parser.parse_args(args_)
     # let argparse do the job of calling the appropriate function after
     # argument parsing is complete
-    args.func(args)
+    return args_.func(args_)
 
 
-if __name__ == '__main__':
-    args = parse_args(sys.argv[1:])
+if __name__ == "__main__":
+    _ = parse_args(sys.argv[1:])
-- 
GitLab