From c5157fb5e34411e602448749c933e50af6d24d2b Mon Sep 17 00:00:00 2001 From: Honglu He <44752310+hehonglu123@users.noreply.github.com> Date: Tue, 9 Jul 2024 20:46:59 -0400 Subject: [PATCH] Initial commit --- .gitattributes | 30 +++++ .gitignore | 192 +++++++++++++++++++++++++++++++ CHANGELOG.md | 91 +++++++++++++++ LICENSE | 29 +++++ README.md | 9 ++ pyproject.toml | 217 +++++++++++++++++++++++++++++++++++ src/project_name/__init__.py | 1 + src/project_name/lib.py | 5 + tests/conftest.py | 1 + tests/test_default.py | 14 +++ 10 files changed, 589 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 CHANGELOG.md create mode 100644 LICENSE create mode 100644 README.md create mode 100644 pyproject.toml create mode 100644 src/project_name/__init__.py create mode 100644 src/project_name/lib.py create mode 100644 tests/conftest.py create mode 100644 tests/test_default.py diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..25bee24 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,30 @@ +# Source files +# ============ +*.pxd text diff=python +*.py text diff=python +*.py3 text diff=python +*.pyw text diff=python +*.pyx text diff=python +*.pyz text diff=python +*.pyi text diff=python + +# Binary files +# ============ +*.db binary +*.p binary +*.pkl binary +*.pickle binary +*.pyc binary export-ignore +*.pyo binary export-ignore +*.pyd binary + +# Jupyter notebook +*.ipynb text eol=lf + +# Note: .db, .p, and .pkl files are associated +# with the python modules ``pickle``, ``dbm.*``, +# ``shelve``, ``marshal``, ``anydbm``, & ``bsddb`` +# (among others). + +# Auto detect text files and perform LF normalization +* text=auto diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d4d5130 --- /dev/null +++ b/.gitignore @@ -0,0 +1,192 @@ +devel/ +logs/ +build/ +bin/ +lib/ +msg_gen/ +srv_gen/ +msg/*Action.msg +msg/*ActionFeedback.msg +msg/*ActionGoal.msg +msg/*ActionResult.msg +msg/*Feedback.msg +msg/*Goal.msg +msg/*Result.msg +msg/_*.py + +# Generated by dynamic reconfigure +*.cfgc +/cfg/cpp/ +/cfg/*.py + +# Ignore generated docs +*.dox +*.wikidoc + +# eclipse stuff +.project +.cproject + +# qcreator stuff +CMakeLists.txt.user + +srv/_*.py +*.pcd +*.pyc +qtcreator-* +*.user + +/planning/cfg +/planning/docs +/planning/src + +*~ + +# Emacs +.#* + +# Catkin custom files +CATKIN_IGNORE + +# 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/ +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/ +cover/ + +# 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 +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .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/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +docs/readme.md + +*.lock \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..88b639c --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,91 @@ + +# project-name Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [CHANGELOG.md][CHANGELOG.md] +and this project adheres to [Semantic Versioning][Semantic Versioning]. + + + + + + + +_______________________________________________________________________________ + +## [0.1.0] - YYYY-MM-DD + +This is the initial version of the project. + +### Added + +- The base project + +[CHANGELOG.md]: https://keepachangelog.com/en/1.1.0/ +[Semantic Versioning]: http://semver.org/ + + + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8d58af1 --- /dev/null +++ b/LICENSE @@ -0,0 +1,29 @@ +BSD 3-Clause License + +Copyright (c) 2024, Rensselaer Polytechnic Institute, Honglu He +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..6dd67ce --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# project-name + +Remember to: + +1. Replace all instances of `project-name` with the real name of the project +2. Replace all instances of `project_name` with the "package name" of the project +3. Rename the source code folder from `project_name` to something more fitting +4. Generate a lock file +5. Rewrite the `README.md` diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..c6402c1 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,217 @@ +[build-system] +requires = ["poetry-core>=1.8.0", "wheel",] +build-backend = "poetry.core.masonry.api" + + +[tool.coverage.run] +branch = true +relative_files = true +omit = [ + ".tox/*", + "tests/*", +] + + +[tool.poetry] +name = "project-name" +version = "0.1.0" +description = "A template Poetry project structure." + +packages = [ + { include = "project_name", from = "src" }, +] + +authors = ["Lari Liuhamo ",] +maintainers = ["Lari Liuhamo ",] + +include = ["CHANGELOG.md", "LICENSE", "py.typed",] +license = "BSD-3-Clause" +readme = "README.md" + +homepage = "" +repository = "" +documentation = "" + +keywords = [ + "python3", +] +classifiers = [ + "Development Status :: 3 - Alpha", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Typing :: Typed", +] + + +[tool.poetry.dependencies] +python = "^3.8.1" +numpy = "^1.24.4" + + +[tool.poetry.group.dev.dependencies] +mypy = "^1.10.0" + + +[tool.poetry.group.linters] +optional = true + + +[tool.poetry.group.linters.dependencies] +ruff = "^0.4.4" + + +[tool.poetry.group.tests] +optional = true + + +[tool.poetry.group.tests.dependencies] +pytest = "^8.2.0" +pytest-cov = "^5.0.0" +tox = "^4.15.0" +tox-gh-actions = "^3.2.0" + + +[tool.poetry.urls] +"Tracker" = "" +"Changelog" = "" + + +[tool.pytest.ini_options] +minversion = "6.0" +addopts = """ +--doctest-modules \ +--cov=./ \ +--cov-append \ +--cov-report html:tests/reports/coverage-html \ +--cov-report xml:tests/reports/coverage.xml \ +--ignore=docs/ +""" +testpaths = [ + "tests", +] + + +[tool.ruff] +select = [ + "A", # Builtins + "ANN", # Annotations + "ARG", # Unused arguments + "B", # Bugbear + "BLE", # Blind except + "C4", # Comprehensions + "C90", # mccabe + "COM", # Commas + "D1", # Undocumented public elements + "D2", # Docstring conventions + "D3", # Triple double quotes + "D4", # Docstring text format + "DTZ", # Datetimes + "EM", # Error messages + "ERA", # Commented-out code + "EXE", # Executable + "F", # Pyflakes + "FA", # __future__ annotations + "FLY", # F-strings + # "FURB", # Refurb + "G", # Logging format + "I", # Isort + "ICN", # Import conventions + "INP", # Disallow PEP-420 (Implicit namespace packages) + "INT", # gettext + "ISC", # Implicit str concat + # "LOG", # Logging + "N", # PEP-8 Naming + "NPY", # Numpy + "PERF", # Unnecessary performance costs + "PGH", # Pygrep hooks + "PIE", # Unnecessary code + "PL", # Pylint + "PT", # Pytest + "PTH", # Use Pathlib + "PYI", # Stub files + "Q", # Quotes + "RET", # Return + "RUF", # Ruff + "RSE", # Raise + "S", # Bandit + "SIM", # Code simplification + "SLF", # Private member access + "SLOT", # __slots__ + "T10", # Debugger + "T20", # Print + "TCH", # Type checking + "TID", # Tidy imports + "TRY", # Exception handling + "UP", # Pyupgrade + "W", # Warnings + "YTT", # sys.version +] +ignore = [ + "D203", # One blank line before class docstring + "D212", # Multi-line summary first line + "PLR0913", # Too many arguments + "Q000", # Single quotes found but double quotes preferred +] +ignore-init-module-imports = true +line-length = 120 +# preview = true +show-fixes = true +src = ["src",] +target-version = "py38" + + +[tool.ruff.flake8-quotes] +docstring-quotes = "double" +multiline-quotes = "double" + + +[tool.ruff.mccabe] +# Unlike Flake8, default to a complexity level of 10. +max-complexity = 10 + + +[tool.ruff.per-file-ignores] +# https://beta.ruff.rs/docs/rules/ +"__init__.py" = ["F401","F403","F405",] +"tests/*" = ["ANN", "ARG", "INP001", "S101",] + + +[tool.ruff.pylint] +max-args = 15 +max-branches = 20 +max-returns = 10 +max-statements = 80 + + +[tool.ruff.flake8-tidy-imports] +ban-relative-imports = "all" + + +[tool.tox] +legacy_tox_ini = """ +[tox] +envlist = py38, py39, py310, py311, pypy3 +skip_missing_interpreters = true + +[gh-actions] +python = + 3.8: py38 + 3.9: py39 + 3.10: py310 + 3.11: py311 + pypy-3.10: pypy3 + +[testenv] +passenv = GITHUB_* +allowlist_externals = poetry + +#commands = +# poetry run pytest +# poetry run coverage report +""" diff --git a/src/project_name/__init__.py b/src/project_name/__init__.py new file mode 100644 index 0000000..0300dae --- /dev/null +++ b/src/project_name/__init__.py @@ -0,0 +1 @@ +"""Stuff 'n' things.""" diff --git a/src/project_name/lib.py b/src/project_name/lib.py new file mode 100644 index 0000000..bef97f7 --- /dev/null +++ b/src/project_name/lib.py @@ -0,0 +1,5 @@ +"""Code.""" + +def adder(first: int, second: int) -> int: + """Lorem Ipsum dolor sit amet.""" + return first + second diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..61e44b4 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1 @@ +"""Contains global fixtures for unit tests.""" diff --git a/tests/test_default.py b/tests/test_default.py new file mode 100644 index 0000000..e1ff00e --- /dev/null +++ b/tests/test_default.py @@ -0,0 +1,14 @@ +"""Stub unit test file.""" + +from project_name.lib import adder + + +def test_stub() -> None: + """Lorem Ipsum.""" + assert True + assert not False + + +def test_adder(): + """Test the adder function.""" + assert adder(3, 4) == 7 # noqa: PLR2004