diff --git a/.gitignore b/.gitignore deleted file mode 100644 index bf65af2..0000000 --- a/.gitignore +++ /dev/null @@ -1,141 +0,0 @@ -# This file lists which files are automatically excluded when you want to push -# something to Git(Hub/Lab) using the program GIT. - -# Ignore the file with auto-generated type hints. -type_info.json - -# Don't include code visualisation structure. -pycallgraph.png - -# Exclude test coverage report from being synced. -cov.xml - -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -pip-wheel-metadata/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -.python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index 23ed3a8..0000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,198 +0,0 @@ -# This file specifies which checks are performed by the pre-commit service. -# The pre-commit service prevents people from pushing code to git that is not -# up to standards. # The reason mirrors are used instead of the actual -# repositories for e.g. black and flake8, is because those repositories also -# need to contain a pre-commit hook file, which they often don't by default. -# So to resolve that, a mirror is created that includes such a file. - -default_language_version: - python: python3.10. # or python3 - - -repos: -# Test if the python code is formatted according to the Black standard. - - repo: https://github.com/Quantco/pre-commit-mirrors-black - rev: 23.1.0 - hooks: - - id: black-conda - args: - - --safe - - --target-version=py36 - -# Test if the python code is formatted according to the flake8 standard. - - repo: https://github.com/Quantco/pre-commit-mirrors-flake8 - rev: 6.0.0 - hooks: - - id: flake8-conda - -# Test if the import statements are sorted correctly. - - repo: https://github.com/PyCQA/isort - rev: 5.12.0 - hooks: - - id: isort - args: ["--profile", "black", --line-length=79] - -# Test if the variable typing is correct. (Variable typing is when you say: -# def is_larger(nr: int) -> bool: instead of def is_larger(nr). It makes -# it explicit what type of input and output a function has. -# - repo: https://github.com/python/mypy - - repo: https://github.com/pre-commit/mirrors-mypy -### - repo: https://github.com/a-t-0/mypy - rev: v1.1.1 - hooks: - - id: mypy - # args: ["--disallow-untyped-calls", "--disallow-untyped-defs"] - args: ["--strict"] - additional_dependencies: - - typeguard - - # TODO: - #--strict - #--disallow-incomplete-defs - #--disallow-any-unimported - #--disallow-any-expr - #--disallow-any-decorated - #--disallow-any-explicit - #--disallow-any-generics - #--disallow-subclassing-any - -# Tests if there are spelling errors in the code. - - repo: https://github.com/codespell-project/codespell - rev: v2.2.2 - hooks: - - id: codespell - -# Performs static code analysis to check for programming errors. - - repo: local - hooks: - - id: pylint - name: pylint - entry: pylint - language: system - types: [python] - args: - [ - "-rn", # Only display messages - "-sn", # Don't display the score - ] - -# Runs additional tests that are created by the pre-commit software itself. - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 - hooks: - # Check user did not add large files. - #- id: check-added-large-files - # Check if `.py` files are written in valid Python syntax. - - id: check-ast - # Require literal syntax when initializing empty or zero Python builtin types. - - id: check-builtin-literals - # Checks if there are filenames that would conflict if case is changed. - - id: check-case-conflict - # Checks if the Python functions have docstrings. - - id: check-docstring-first - # Checks if any `.sh` files have a shebang like #!/bin/bash - - id: check-executables-have-shebangs - # Verifies json format of any `.json` files in repo. - - id: check-json - # Checks if there are any existing merge conflicts caused by the commit. - - id: check-merge-conflict - # Checks for symlinks which do not point to anything. - - id: check-symlinks - # Checks if xml files are formatted correctly. - - id: check-xml - # Checks if .yml files are valid. - - id: check-yaml - # Checks if debugger imports are performed. - - id: debug-statements - # Detects symlinks changed to regular files with content path symlink was pointing to. - - id: destroyed-symlinks - # Checks if you don't accidentally push a private key. - - id: detect-private-key - # Replaces double quoted strings with single quoted strings. - # This is not compatible with Python Black. - #- id: double-quote-string-fixer - # Makes sure files end in a newline and only a newline. - - id: end-of-file-fixer - # Removes UTF-8 byte order marker. - - id: fix-byte-order-marker - # Add <# -*- coding: utf-8 -*-> to the top of python files. - #- id: fix-encoding-pragma - # Checks if there are different line endings, like \n and crlf. - - id: mixed-line-ending - # Asserts `.py` files in folder `/test/` (by default:) end in `_test.py`. - - id: name-tests-test - # Override default to check if `.py` files in `/test/` START with `test_`. - args: ['--django'] - # Ensures JSON files are properly formatted. - - id: pretty-format-json - args: ['--autofix'] - # Sorts entries in requirements.txt and removes incorrect pkg-resources entries. - - id: requirements-txt-fixer - # Sorts simple YAML files which consist only of top-level keys. - - id: sort-simple-yaml - # Removes trailing whitespaces at end of lines of .. files. - - id: trailing-whitespace - - - - - - - repo: https://github.com/PyCQA/autoflake - rev: v2.0.1 - hooks: - - id: autoflake - args: ["--in-place", "--remove-unused-variables", "--remove-all-unused-imports", "--recursive"] - name: AutoFlake - description: "Format with AutoFlake" - stages: [commit] - - - repo: https://github.com/PyCQA/bandit - rev: 1.7.4 - hooks: - - id: bandit - name: Bandit - stages: [commit] - -# Enforces formatting style in Markdown (.md) files. - - repo: https://github.com/executablebooks/mdformat - rev: 0.7.16 - hooks: - - id: mdformat - #args: ["-r ~MD013"] - additional_dependencies: - - mdformat-toc - - mdformat-gfm - - mdformat-black - - #- repo: https://github.com/MarcoGorelli/absolufy-imports - # rev: v0.3.1 - # hooks: - # - id: absolufy-imports - # files: '^src/.+\.py$' - # args: ['--never', '--application-directories', 'src'] - - - repo: https://github.com/myint/docformatter - rev: v1.6.0.rc1 - hooks: - - id: docformatter - - - repo: https://github.com/pre-commit/pygrep-hooks - rev: v1.10.0 - hooks: - - id: python-use-type-annotations - - id: python-check-blanket-noqa - - id: python-check-blanket-type-ignore - -# Updates the syntax of `.py` files to the specified python version. -# It is not compatible with: pre-commit hook: fix-encoding-pragma - - repo: https://github.com/asottile/pyupgrade - rev: v3.3.1 - hooks: - - id: pyupgrade - args: [--py38-plus] - - - - repo: https://github.com/markdownlint/markdownlint - rev: v0.12.0 - hooks: - - id: markdownlint diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 09b298e..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "explorer.confirmDragAndDrop": false, - "files.exclude": { - "**/.coverage.*": true, - "**/__init__*": true, - "**/__pycache__*": true - }, - "searchOpenAllResults.delay": 150, - "searchOpenAllResults.fileResultsLimit": 300, - "searchOpenAllResults.resultsLimit": 250, - "window.zoomLevel": 0, - "workbench.colorTheme": "Default High Contrast" -} diff --git a/README.md b/README.md deleted file mode 100644 index 5defa9d..0000000 --- a/README.md +++ /dev/null @@ -1,62 +0,0 @@ -# Python Repository Template - -[![Python 3.10][python_badge]](https://www.python.org/downloads/release/python-3106/) -[![License: AGPL v3][agpl3_badge]](https://www.gnu.org/licenses/agpl-3.0) -[![Code Style: Black][black_badge]](https://github.com/ambv/black) - -Example Python repository to quickly fork into new clean environment. - -- typechecking -- pre-commit - -## Usage - -First install this pip package with: - -```bash -pip install pythontemplate -``` - -Then run: - -```py -python -m src.pythontemplate -``` - -## Developer - -```bash -pre-commit install -pre-commit autoupdate -pre-commit run --all -``` - -## Publish pip package - -Build the pip package with: - -```bash -pip install --upgrade pip setuptools wheel -pip install twine -``` - -Install the pip package locally with: - -```bash -pip install -e . -``` - -Upload the pip package to the world with: - -```bash -rm -r dist -rm -r build -python3 setup.py sdist bdist_wheel -python3 -m twine upload dist/\* -``` - - - -[agpl3_badge]: https://img.shields.io/badge/License-AGPL_v3-blue.svg -[black_badge]: https://img.shields.io/badge/code%20style-black-000000.svg -[python_badge]: https://img.shields.io/badge/python-3.6-blue.svg diff --git a/adder.py b/adder.py new file mode 100644 index 0000000..037356c --- /dev/null +++ b/adder.py @@ -0,0 +1,2 @@ +def add_two(x): + return x + 2 \ No newline at end of file diff --git a/environment.yml b/environment.yml deleted file mode 100644 index 6ef6449..0000000 --- a/environment.yml +++ /dev/null @@ -1,67 +0,0 @@ -# This file is to automatically configure your environment. It allows you to -# run the code with a single command without having to install anything -# (extra). - -# First run: conda env create --file environment.yml -# If you change this file, run: conda env update --file environment.yml - -# Conda configuration settings. (Specify which modules/packages are installed.) -name: pythontemplate -channels: - - conda-forge -dependencies: -# Specify specific python version. - - python=3.10 -# Pre-commit packages for code quality: -# Run python tests. - - pytest-cov -# Turns relative import paths into absolute import paths. - - absolufy-imports -# Auto format Python code to make it flake8 compliant. - - autoflake -# Scan Python code for security issues. - - bandit -# Code formatting compliance. - - black -# Correct code misspellings. - - codespell -# Verify percentage of code that has at least 1 test. - - coverage -# Auto formats the Python documentation written in the code. - - docformatter -# Auto generate docstrings. - - flake8 -# Auto sort the import statements. - - isort -# Auto format Markdown files. - - mdformat -# Auto check static typing. - - mypy -# Auto generate documentation. - - pdoc3 -# Another static type checker for python like mypy. - - pyright -# Include GitHub pre-commit hook. - - pre-commit -# Visualise the structure of the code based on a command. - - pycallgraph2 -# Automatically upgrades Python syntax to the new Python version syntax. - - pyupgrade -# Auto generate docstrings. - - pyment -# Auto check programming style aspects. - - pylint -# Enable publishing the pip package. - - twine -# Ensure the python function arguments are verified at runtime. - - typeguard -# Enable creating the pip package. - - setuptools - - wheel -# pip packages: - - pip - - pip: - # Seems to be an autoformatter like black, but installed using npm instead of pip. - - prettier - # Allow for auto generation of type-hints during runtime. - - pyannotate diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index 20aef3f..0000000 --- a/pyproject.toml +++ /dev/null @@ -1,61 +0,0 @@ -# This is used to configure the black, isort and mypy such that the packages don't conflict. -# This file is read by the pre-commit program. -[tool.black] -line-length = 79 -include = '\.pyi?$' -exclude = ''' -/( - \.git - | \.mypy_cache - | build - | dist -)/ -''' - - -[tool.coverage.run] -# Due to a strange bug with xml output of coverage.py not writing the full-path -# of the sources, the full root directory is presented as a source alongside -# the main package. As a result any importable Python file/package needs to be -# included in the omit -source = [ - "foo", - ".", -] -# Excludes the following directories from the coverage report -omit = [ - "tests/*", - "setup.py", -] - - -[tool.isort] -profile = "black" - - -[tool.mypy] -ignore_missing_imports = true - - -[tool.pylint.basic] -bad-names=[] -[tool.pylint.messages_control] -# Example: Disable error on needing a module-level docstring -disable=[ - "import-error", - "invalid-name", - "fixme", -] - - -[tool.pytest.ini_options] -# Runs coverage.py through use of the pytest-cov plugin -# An xml report is generated and results are output to the terminal - -# TODO: Disable this line to disable CLI coverage reports when running tests. -# addopts = "--cov --cov-report xml:cov.xml --cov-report term" - -# Sets the minimum allowed pytest version -minversion = 5.0 -# Sets the path where test files are located (Speeds up Test Discovery) -testpaths = ["tests"] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 3aa1079..0000000 --- a/requirements.txt +++ /dev/null @@ -1,7 +0,0 @@ -# Allow for auto generation of type-hints during runtime. -pyannotate -# Run python tests. -pytest-cov -# This file ensures that the pre-commit service is ran every time you commit. -# Ensure the python function arguments are verified at runtime. -typeguard diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index a2b1e65..0000000 --- a/setup.cfg +++ /dev/null @@ -1,55 +0,0 @@ -[metadata] -name = pythontemplate -version = attr: pythontemplate.__version__ -description = Selenium browser controller for apt Firefox on Ubuntu 22.10 -long_description = file: README.md -long_description_content_type = text/markdown -url = https://github.com/Hiveminds/pythontemplate -author = a-t-0 -author_email = no-email@no-email.org -maintainer = a-t-0 -maintainer_email = no-email@no-email.org -license = AGPLv3 -license_file = licence -classifiers = - Development Status :: 2 - Pre-Alpha - Environment :: Console - Intended Audience :: Developers - License :: OSI Approved :: GNU Affero General Public License v3 - Programming Language :: Python - Programming Language :: Python :: 3 - Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.10 - Topic :: Internet :: WWW/HTTP :: Browsers - -[options] -packages = find: -package_dir = - =src -# Dependencies -install_requires = - pyannotate>=1.2.0 - pytest-cov>=4.0.0 - typeguard>=2.13.3 -python_requires = >=3.10 - -[options.packages.find] -where = src - -[options.entry_points] -console_scripts = - pythontemplate = pythontemplate:main - -[bdist_wheel] -universal = 1 - -[mypy] -check_untyped_defs = true -disallow_any_generics = true -disallow_incomplete_defs = true -disallow_untyped_defs = true -no_implicit_optional = true -warn_unused_ignores = true - -[mypy-tests.*] -disallow_untyped_defs = false diff --git a/setup.py b/setup.py deleted file mode 100644 index 497f4b9..0000000 --- a/setup.py +++ /dev/null @@ -1,10 +0,0 @@ -"""Packaging logic for pythontemplate.""" -from __future__ import annotations - -import os -import sys - -import setuptools - -sys.path.insert(0, os.path.join(os.path.dirname(__file__), "src")) -setuptools.setup() diff --git a/src/__init__.py b/src/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/pythontemplate/__init__.py b/src/pythontemplate/__init__.py deleted file mode 100644 index ad568eb..0000000 --- a/src/pythontemplate/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -"""Contains the project versioning.""" -__version__ = "0.0.7" -__version_info__ = tuple(int(i) for i in __version__.split(".") if i.isdigit()) diff --git a/src/pythontemplate/__main__.py b/src/pythontemplate/__main__.py deleted file mode 100644 index 614bc1d..0000000 --- a/src/pythontemplate/__main__.py +++ /dev/null @@ -1,6 +0,0 @@ -"""Entry point for the project.""" - -from src.pythontemplate.adder import add_two - -some_val: int = 2 -print(f"Hello world. {some_val}+2={add_two(x=some_val)}") diff --git a/src/pythontemplate/adder.py b/src/pythontemplate/adder.py deleted file mode 100644 index bfadfd7..0000000 --- a/src/pythontemplate/adder.py +++ /dev/null @@ -1,10 +0,0 @@ -"""Example python file with a function.""" - - -from typeguard import typechecked - - -@typechecked -def add_two(*, x: int) -> int: - """Adds a value to an incoming number.""" - return x + 2 diff --git a/test/__init__.py b/test/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/test/test_adder.py b/test/test_adder.py deleted file mode 100644 index be8268f..0000000 --- a/test/test_adder.py +++ /dev/null @@ -1,26 +0,0 @@ -"""Tests whether the adder function indeed adds 2 to a given input.""" -import unittest - -from typeguard import typechecked - -from src.pythontemplate.adder import add_two - - -class Test_adder(unittest.TestCase): - """Object used to test a parse_creds function.""" - - # Initialize test object - @typechecked - def __init__(self, *args, **kwargs): # type:ignore[no-untyped-def] - super().__init__(*args, **kwargs) - - @typechecked - def test_add_two_input_5(self) -> None: - """Tests if add_two function adds 2 to an integer.""" - actual_result: int = add_two(x=5) - expected_result: int = 7 - self.assertEqual(expected_result, actual_result) - - -if __name__ == "__main__": - unittest.main()