From 86040c4d4fd783217b22ef990a1683b1f2432615 Mon Sep 17 00:00:00 2001 From: Florian Hines Date: Fri, 9 Sep 2022 11:30:50 -0500 Subject: [PATCH 01/26] Add a flake8 config Add a flake8 config --- .flake8 | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .flake8 diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..cf3fdb5 --- /dev/null +++ b/.flake8 @@ -0,0 +1,7 @@ +[flake8] +ignore = W503, C901, ANN101 +max-line-length = 88 +exclude = files_airflow_ext,cookiecutter +max-complexity = 10 +docstring-convention = google +allow-star-arg-any = true From 96221245f5b8dcb24d531aee750a38c918db4b44 Mon Sep 17 00:00:00 2001 From: Florian Hines Date: Fri, 9 Sep 2022 11:32:56 -0500 Subject: [PATCH 02/26] Add basic pre-commit-config --- .pre-commit-config.yaml | 44 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..7912c49 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,44 @@ +ci: + autofix_prs: false + autoupdate_schedule: weekly + autoupdate_commit_msg: 'chore: pre-commit autoupdate' + +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.3.0 + hooks: + - id: check-json + - id: check-toml + - id: check-yaml + - id: end-of-file-fixer + exclude: (docs/.*|samples/.*\.json) + - id: trailing-whitespace + exclude: | + (?x)^( + .bumpversion.cfg + )$ + +- repo: https://github.com/psf/black + rev: 22.8.0 + hooks: + - id: black + +- repo: https://github.com/pycqa/isort + rev: 5.10.1 + hooks: + - id: isort + +- repo: https://github.com/pycqa/flake8 + rev: 5.0.4 + hooks: + - id: flake8 + additional_dependencies: + - darglint==1.8.1 + - flake8-annotations==2.9.0 + - flake8-docstrings==1.6.0 + +- repo: https://github.com/asottile/pyupgrade + rev: v2.37.3 + hooks: + - id: pyupgrade + args: [--py37-plus] From 80a5ca85f28bb333d9e4d115342063a5c8e71dbe Mon Sep 17 00:00:00 2001 From: Florian Hines Date: Fri, 9 Sep 2022 11:34:50 -0500 Subject: [PATCH 03/26] Create semantic.yml --- .github/semantic.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/semantic.yml diff --git a/.github/semantic.yml b/.github/semantic.yml new file mode 100644 index 0000000..4e46853 --- /dev/null +++ b/.github/semantic.yml @@ -0,0 +1,30 @@ +# Config ref: https://github.com/Ezard/semantic-prs + +# Validate the PR title, and ignore all commit messages +titleOnly: true + +# Provides a custom URL for the "Details" link, which appears next to the success/failure message from the app: +targetUrl: https://github.com/meltano/basic-python-template/blob/main/CONTRIBUTING.md#semantic-pull-requests + +# The values allowed for the "type" part of the PR title/commit message. +# e.g. for a PR title/commit message of "feat: add some stuff", the type would be "feat" +types: + - ci + - chore + - build + - docs + - feat + - fix + - perf + - refactor + - revert + - style + - test + +# The values allowed for the "scope" part of the PR title/commit message. +# e.g. for a PR title/commit message of "feat(awesome-feature): add some stuff", +# the scope would be "awesome-feature" +# edit or add scopes are needed +scopes: + - deps # production dependencies + - deps-dev # development depencencies (testing, linting, etc.) From 3544dbbc208f81464ed51548839b6ad2c3d9b5f3 Mon Sep 17 00:00:00 2001 From: Florian Hines Date: Fri, 9 Sep 2022 11:35:44 -0500 Subject: [PATCH 04/26] Create CODEOWNERS --- .github/CODEOWNERS | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..a00a6e0 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,7 @@ +# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners + +# Ending a path in a `/` will specify the code owners for every file +# nested in that directory, on any level + +# Default owners +* @meltano/engineering From 5d303fb3e2ce6f9afac72accf03909b0cea8ee0f Mon Sep 17 00:00:00 2001 From: Florian Hines Date: Fri, 9 Sep 2022 11:37:23 -0500 Subject: [PATCH 05/26] Create codeql-analysis.yml --- .github/workflows/codeql-analysis.yml | 65 +++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..ac07d7f --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,65 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +name: "CodeQL" + +on: + push: + branches: [ "main" ] + pull_request: {} + schedule: + - cron: '37 10 * * 5' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'python' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + # ℹ️ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 From 92b730a6329c93a27099e8f89ccf73bd175052b4 Mon Sep 17 00:00:00 2001 From: Florian Hines Date: Fri, 9 Sep 2022 11:41:10 -0500 Subject: [PATCH 06/26] Create bug.yml --- .github/ISSUE_TEMPLATE/bug.yml | 58 ++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug.yml diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml new file mode 100644 index 0000000..332a3af --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -0,0 +1,58 @@ +name: Bug Report +description: File a bug report +title: "[Bug]: " +labels: ["kind/Bug"] +assignees: + - meltano/engineering + +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this bug report! + - type: input + id: package_version + attributes: + label: Package Version + description: Version/commit hash of this package that you are using + placeholder: "0.0.1" + validations: + required: true + - type: dropdown + id: python_version + attributes: + label: Python Version + description: Version of Python you are using + options: + - "3.6 (deprecated)" + - "3.7" + - "3.8" + - "3.9" + - "3.10" + - "NA" + validations: + required: true + - type: input + id: os + attributes: + label: Operating System + description: What operating system you are using + placeholder: "Windows" + validations: + required: true + - type: textarea + id: what-happened + attributes: + label: Description + description: Describe what you were trying to get done + placeholder: Tell us what happened, what went wrong, and what you expected to happen + validations: + required: true + - type: textarea + id: failing-code + attributes: + label: Code + description: Paste the failing code and/or traceback, if applicable + render: python + validations: + required: false From 97c90c2a2ced04903b1b1b0c9dc62f1787e2530f Mon Sep 17 00:00:00 2001 From: Florian Hines <syn@ronin.io> Date: Fri, 9 Sep 2022 11:45:46 -0500 Subject: [PATCH 07/26] Create CONTRIBUTING.md --- CONTRIBUTING.md | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..727cfd3 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,47 @@ +# Contributing to the SDK + +Let's build together! Please see our [Contributor Guide](https://docs.meltano.com/contribute/) +for more information on contributing to Meltano. + +We believe that everyone can contribute and we welcome all contributions. + +Chat with us in [#contributing](https://meltano.slack.com/archives/C013Z450LCD) on [Slack](https://meltano.com/slack). + +Contributors are expected to follow our [Code of Conduct](https://docs.meltano.com/contribute/#code-of-conduct). + +## Semantic Pull Requests + +This repo uses the [semantic-prs](https://github.com/Ezard/semantic-prs) GitHub app to check all PRs againts the conventional commit syntax. + +Pull requests should be named according to the conventional commit syntax to streamline changelog and release notes management. We encourage (but do not require) the use of conventional commits in commit messages as well. + +In general, PR titles should follow the format "<type>: <desc>", where type is any one of these: + +- `ci` +- `chore` +- `build` +- `docs` +- `feat` +- `fix` +- `perf` +- `refactor` +- `revert` +- `style` +- `test` + +More advanced rules and settings can be found within the file [`.github/semantic.yml`](https://github.com/meltano/basic-python-template/blob/main/.github/semantic.yml). + +## Workspace Development Strategies for Meltano Python packages + +### Universal Code Formatting + +- From the [Black](https://black.readthedocs.io) website: + > By using Black, you agree to cede control over minutiae of hand-formatting. In return, Black gives you speed, determinism, and freedom from pycodestyle nagging about formatting. You will save time and mental energy for more important matters. **Black makes code review faster by producing the smallest diffs possible.** Blackened code looks the same regardless of the project you’re reading. **Formatting becomes transparent after a while and you can focus on the content instead.** + +### Pervasive Python Type Hints + +Type hints allow us to spend less time reading documentation. Public modules should be checked for type annotations on all methods and functions. + +### Docstring convention + +All public modules in the Meltano python packages are checked for the presence of docstrings in classes and functions. We follow the [Google Style convention](https://www.sphinx-doc.org/en/master/usage/extensions/example_google.html) for Python docstrings so functions are required to have a description of every argument and the return value, if applicable. From 100cead420873ca78e4d49a7bc520798f901d437 Mon Sep 17 00:00:00 2001 From: Florian Hines <syn@ronin.io> Date: Fri, 9 Sep 2022 12:02:22 -0500 Subject: [PATCH 08/26] Add basic poetry skaffolding --- README.md | 13 ++++++++++ basic_python_template/__init__.py | 0 pyproject.toml | 40 +++++++++++++++++++++++++++++++ tests/__init__.py | 0 4 files changed, 53 insertions(+) create mode 100644 basic_python_template/__init__.py create mode 100644 pyproject.toml create mode 100644 tests/__init__.py diff --git a/README.md b/README.md index 64e1158..c1e5572 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,15 @@ # basic-python-template + A github repo template for generic Meltano python projects + +## using this template + +1. create a new github project - selecting this repo as the source template +2. Update `pyproject.toml` renaming the epo and python packages as needed +3. Rename or remove the `basic_python_template` directory as needed +4. Update or remove the `tests` as needed +5. Take a look at `.github` and update the issue templates and semantic prs workflow as needed +6. Install any needed github app (e.g. semantic prs) +7. Verify the team permissions and settings for the repo +8. Replace this README.md with something more appropriate +9. Go forth and build something cool! diff --git a/basic_python_template/__init__.py b/basic_python_template/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..e0aeb77 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,40 @@ +[tool.poetry] +name = "basic-python-template" +version = "0.1.0" +description = "" +authors = ["Meltano Team and Contributors"] +maintainers = ["Meltano Team and Contributors"] +readme = "README.md" +homepage = "https://meltano.com" +repository = "https://github.com/meltano/basic-python-template" +license = "Apache 2.0" + +packages = [{include = "basic_python_template"}] + +[tool.poetry.dependencies] +python = "<3.10,>=3.7" + +[tool.poetry.urls] +"Issue Tracker" = "https://github.com/meltano/basic-python-template/issues" +"Twitter" = "https://twitter.com/meltanodata/" +"Changelog" = "https://github.com/meltano/basic-python-template/blob/main/CHANGELOG.md" +"Slack" = "https://meltano.com/slack" +"Youtube" = "https://www.youtube.com/meltano" + +[tool.poetry.dev-dependencies] +pytest = "^5.2" +isort = "^5.10.1" +black = "^22.6" +darglint = "^1.8.0" +flake8 = "^3.9.0" +flake8-annotations = "^2.9.1" +flake8-docstrings = "^1.6.0" + +[tool.isort] +profile = "black" +multi_line_output = 3 # Vertical Hanging Indent +src_paths = "basic_python_template" + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 From 295191385011e46c1748eebe327af26f60392792 Mon Sep 17 00:00:00 2001 From: Florian Hines <syn@ronin.io> Date: Fri, 9 Sep 2022 12:08:07 -0500 Subject: [PATCH 09/26] Update readme with recommended repo settings --- README.md | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c1e5572..1917d95 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,17 @@ A github repo template for generic Meltano python projects 4. Update or remove the `tests` as needed 5. Take a look at `.github` and update the issue templates and semantic prs workflow as needed 6. Install any needed github app (e.g. semantic prs) -7. Verify the team permissions and settings for the repo +7. Verify the team permissions and settings for the repo (recommended settings below) + 1. Access - Collaborators and teams + 1. @aaronsteers -> role: admin + 2. @meltano/engineer -> role: maintain + 3. @meltano/team -> role: write + 2. Branches - Branch protection rules + 1. Require pull request for merging + 1. Require approvals -> Required number of approvals: 1 + 2. Require status checks to pass before merge + 3. Require conversations to be resolved before merge + 3. Code security and analysis + 1. Code scanning -> Enabled (config already supplied in repo) 8. Replace this README.md with something more appropriate -9. Go forth and build something cool! +9. Go forth and build something cool! From 86030b9e93be38b51476d1df7bfaa5d8d8854cd0 Mon Sep 17 00:00:00 2001 From: Florian Hines <syn@ronin.io> Date: Fri, 9 Sep 2022 12:10:01 -0500 Subject: [PATCH 10/26] Link to gh docs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1917d95..8876ead 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ A github repo template for generic Meltano python projects ## using this template -1. create a new github project - selecting this repo as the source template +1. create a new github project - selecting this repo as the source template - [doc: creating a repo from a template](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template) 2. Update `pyproject.toml` renaming the epo and python packages as needed 3. Rename or remove the `basic_python_template` directory as needed 4. Update or remove the `tests` as needed From 6e4c977a5041a1ce1f18a2137d062db934a78ee2 Mon Sep 17 00:00:00 2001 From: Florian Hines <syn@ronin.io> Date: Fri, 9 Sep 2022 12:12:27 -0500 Subject: [PATCH 11/26] Generic pytest ci run --- .github/workflows/test.yml | 35 +++++++++++++++++++++++++++++++++++ README.md | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..4e42345 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,35 @@ +name: Test + +on: + pull_request: + types: [opened, synchronize, reopened] + push: + branches: [main] + workflow_dispatch: + inputs: {} + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.7", "3.8", "3.9", "3.10"] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Poetry + run: | + pipx install poetry + poetry --version + - name: Install dependencies + run: | + poetry install + - name: Test with pytest + run: | + poetry run pytest \ No newline at end of file diff --git a/README.md b/README.md index 8876ead..649c54a 100644 --- a/README.md +++ b/README.md @@ -23,4 +23,4 @@ A github repo template for generic Meltano python projects 3. Code security and analysis 1. Code scanning -> Enabled (config already supplied in repo) 8. Replace this README.md with something more appropriate -9. Go forth and build something cool! +9. Go forth and build something cool! From d3c6f1b1e7ba6ddb402408e04054967afbc17e70 Mon Sep 17 00:00:00 2001 From: Florian Hines <syn@ronin.io> Date: Fri, 9 Sep 2022 12:24:35 -0500 Subject: [PATCH 12/26] Add basic test --- .github/workflows/test.yml | 2 +- basic_python_template/__init__.py | 3 +++ pyproject.toml | 3 +++ tests/__init__.py | 1 + tests/test_basic_python_template.py | 5 +++++ 5 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 tests/test_basic_python_template.py diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4e42345..0202805 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,4 +32,4 @@ jobs: poetry install - name: Test with pytest run: | - poetry run pytest \ No newline at end of file + poetry run pytest diff --git a/basic_python_template/__init__.py b/basic_python_template/__init__.py index e69de29..ce2eccb 100644 --- a/basic_python_template/__init__.py +++ b/basic_python_template/__init__.py @@ -0,0 +1,3 @@ +"""Example package. Update/remove/rename as needed.""" + +__version__ = "0.1.0" diff --git a/pyproject.toml b/pyproject.toml index e0aeb77..fcc00e1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,6 +30,9 @@ flake8 = "^3.9.0" flake8-annotations = "^2.9.1" flake8-docstrings = "^1.6.0" +[tool.poetry.group.dev.dependencies] +pre-commit = "^2.20.0" + [tool.isort] profile = "black" multi_line_output = 3 # Vertical Hanging Indent diff --git a/tests/__init__.py b/tests/__init__.py index e69de29..f18cb54 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -0,0 +1 @@ +"""Example test. Update/remove/ignore as needed.""" diff --git a/tests/test_basic_python_template.py b/tests/test_basic_python_template.py new file mode 100644 index 0000000..ef42569 --- /dev/null +++ b/tests/test_basic_python_template.py @@ -0,0 +1,5 @@ +from basic_python_template import __version__ + + +def test_version(): + assert __version__ == '0.1.0' \ No newline at end of file From 77ca06309c3beb408769672b79a697f9465ad639 Mon Sep 17 00:00:00 2001 From: Florian Hines <syn@ronin.io> Date: Fri, 9 Sep 2022 17:05:44 -0500 Subject: [PATCH 13/26] Update CONTRIBUTING.md --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 727cfd3..30f60a3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,4 @@ -# Contributing to the SDK +# Contributing to this package Let's build together! Please see our [Contributor Guide](https://docs.meltano.com/contribute/) for more information on contributing to Meltano. From 764cdf647a049f0ae521e033cad1616cd8c8c503 Mon Sep 17 00:00:00 2001 From: Florian Hines <syn@ronin.io> Date: Fri, 9 Sep 2022 17:07:59 -0500 Subject: [PATCH 14/26] Update README.md --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 649c54a..6494812 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,18 @@ -# basic-python-template +# Basic-python-template A github repo template for generic Meltano python projects -## using this template +## Using this template 1. create a new github project - selecting this repo as the source template - [doc: creating a repo from a template](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template) -2. Update `pyproject.toml` renaming the epo and python packages as needed +2. Update `pyproject.toml` renaming the repo and python packages as needed 3. Rename or remove the `basic_python_template` directory as needed 4. Update or remove the `tests` as needed 5. Take a look at `.github` and update the issue templates and semantic prs workflow as needed -6. Install any needed github app (e.g. semantic prs) -7. Verify the team permissions and settings for the repo (recommended settings below) +6. Visit the https://github.com/meltano/internal-tech-ops and open issue requesting that the following two github apps be installed for your new repo: + 1. semantic prs + 2. pre-commit ci +7. Verify the team permissions and settings for the repo (recommended settings below), you can ask in the https://github.com/meltano/internal-tech-ops for assitance with permissions as required. 1. Access - Collaborators and teams 1. @aaronsteers -> role: admin 2. @meltano/engineer -> role: maintain From c44ee840adc4d58168012822aa7a6526da04dd40 Mon Sep 17 00:00:00 2001 From: Florian Hines <syn@ronin.io> Date: Fri, 9 Sep 2022 17:11:07 -0500 Subject: [PATCH 15/26] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6494812..6614195 100644 --- a/README.md +++ b/README.md @@ -8,11 +8,11 @@ A github repo template for generic Meltano python projects 2. Update `pyproject.toml` renaming the repo and python packages as needed 3. Rename or remove the `basic_python_template` directory as needed 4. Update or remove the `tests` as needed -5. Take a look at `.github` and update the issue templates and semantic prs workflow as needed -6. Visit the https://github.com/meltano/internal-tech-ops and open issue requesting that the following two github apps be installed for your new repo: +5. Take a look at the `.github` dir and update the issue templates and semantic prs workflow as needed +6. Visit the [internal-tech-ops](https://github.com/meltano/internal-tech-ops) and [open an issue](https://github.com/meltano/internal-tech-ops/issues/new?title=github%20apps%20install%20request) requesting that the following two github apps be installed for your new repo: 1. semantic prs 2. pre-commit ci -7. Verify the team permissions and settings for the repo (recommended settings below), you can ask in the https://github.com/meltano/internal-tech-ops for assitance with permissions as required. +7. Verify the team permissions and settings for the repo (recommended settings below). You can also create an issue in [internal-tech-ops](https://github.com/meltano/internal-tech-ops) for additional assistance/validation/etc. 1. Access - Collaborators and teams 1. @aaronsteers -> role: admin 2. @meltano/engineer -> role: maintain From 1e7c4fa1154d488e1f50d9faeaeb4c5f489056e1 Mon Sep 17 00:00:00 2001 From: Florian Hines <syn@ronin.io> Date: Tue, 13 Sep 2022 09:28:44 -0500 Subject: [PATCH 16/26] pr feedback --- .github/workflows/test.yml | 3 +-- .pre-commit-config.yaml | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0202805..3cfaf35 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,8 +1,7 @@ name: Test on: - pull_request: - types: [opened, synchronize, reopened] + pull_request: {} push: branches: [main] workflow_dispatch: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7912c49..b93592c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,5 @@ ci: - autofix_prs: false + autofix_prs: true autoupdate_schedule: weekly autoupdate_commit_msg: 'chore: pre-commit autoupdate' From eaaf2d280d78440c4beb6a27fd7b2bf9683916b5 Mon Sep 17 00:00:00 2001 From: Florian Hines <syn@ronin.io> Date: Tue, 13 Sep 2022 09:29:07 -0500 Subject: [PATCH 17/26] update flake ignores for tests --- .flake8 | 4 +++- tests/test_basic_python_template.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.flake8 b/.flake8 index cf3fdb5..136821a 100644 --- a/.flake8 +++ b/.flake8 @@ -1,7 +1,9 @@ [flake8] ignore = W503, C901, ANN101 max-line-length = 88 -exclude = files_airflow_ext,cookiecutter max-complexity = 10 docstring-convention = google allow-star-arg-any = true +per-file-ignores = + # Don't require docstrings or type annotations in tests + tests/*:D100,D102,D103,D104,DAR,ANN diff --git a/tests/test_basic_python_template.py b/tests/test_basic_python_template.py index ef42569..816a407 100644 --- a/tests/test_basic_python_template.py +++ b/tests/test_basic_python_template.py @@ -2,4 +2,4 @@ def test_version(): - assert __version__ == '0.1.0' \ No newline at end of file + assert __version__ == "0.1.0" From f43562221b4a4b5cba1fd206f52fbb2518051bc7 Mon Sep 17 00:00:00 2001 From: Florian Hines <syn@ronin.io> Date: Tue, 13 Sep 2022 09:55:17 -0500 Subject: [PATCH 18/26] Update pyproject.toml Co-authored-by: Will Da Silva <will@willdasilva.xyz> --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index fcc00e1..163177d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ license = "Apache 2.0" packages = [{include = "basic_python_template"}] [tool.poetry.dependencies] -python = "<3.10,>=3.7" +python = "<3.11,>=3.7" [tool.poetry.urls] "Issue Tracker" = "https://github.com/meltano/basic-python-template/issues" From ff5dae7aaef41b9b5e62e5160b9a2b79ffec0d57 Mon Sep 17 00:00:00 2001 From: Florian Hines <syn@ronin.io> Date: Tue, 13 Sep 2022 10:45:22 -0500 Subject: [PATCH 19/26] Ad mypy config --- pyproject.toml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index fcc00e1..aeb7426 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,12 +32,22 @@ flake8-docstrings = "^1.6.0" [tool.poetry.group.dev.dependencies] pre-commit = "^2.20.0" +mypy = "^0.971" [tool.isort] profile = "black" multi_line_output = 3 # Vertical Hanging Indent src_paths = "basic_python_template" +[tool.mypy] +disallow_untyped_defs = true +check_untyped_defs = true +no_implicit_optional = true +warn_return_any = true +warn_unused_ignores = true +show_error_codes = true + + [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" From 75d202401e59f5ca2e4b799e04d220d34f43ec17 Mon Sep 17 00:00:00 2001 From: Florian Hines <syn@ronin.io> Date: Tue, 13 Sep 2022 10:46:15 -0500 Subject: [PATCH 20/26] Don't make pytest a module by default --- tests/__init__.py | 1 - 1 file changed, 1 deletion(-) delete mode 100644 tests/__init__.py diff --git a/tests/__init__.py b/tests/__init__.py deleted file mode 100644 index f18cb54..0000000 --- a/tests/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Example test. Update/remove/ignore as needed.""" From 092bebf0296686ef6d17e0df4dd2d4921da7e165 Mon Sep 17 00:00:00 2001 From: Florian Hines <syn@ronin.io> Date: Tue, 13 Sep 2022 10:47:27 -0500 Subject: [PATCH 21/26] Clean up extra newline --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2e229cc..0554639 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,7 +47,6 @@ warn_return_any = true warn_unused_ignores = true show_error_codes = true - [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" From 627306c78aea968f82942a20a83ff31b0ba2a734 Mon Sep 17 00:00:00 2001 From: Florian Hines <syn@ronin.io> Date: Tue, 13 Sep 2022 10:51:44 -0500 Subject: [PATCH 22/26] Mention mypy in contrib guide --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 30f60a3..3d9a165 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -40,7 +40,7 @@ More advanced rules and settings can be found within the file [`.github/semantic ### Pervasive Python Type Hints -Type hints allow us to spend less time reading documentation. Public modules should be checked for type annotations on all methods and functions. +Type hints allow us to spend less time reading documentation. This repo template ships with a default mypy config, it can be relaxed *if* needed on a per-module/per-import basis. ### Docstring convention From f805cd11a7819e7bcd58c192ef73ab6805046086 Mon Sep 17 00:00:00 2001 From: Florian Hines <syn@ronin.io> Date: Tue, 13 Sep 2022 10:56:17 -0500 Subject: [PATCH 23/26] Add mypy check to test workflow --- .github/workflows/test.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3cfaf35..1759dea 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,7 +8,7 @@ on: inputs: {} jobs: - build: + tests: runs-on: ubuntu-latest strategy: @@ -32,3 +32,6 @@ jobs: - name: Test with pytest run: | poetry run pytest + - name: Run mypy + run: | + poetry run mypy . From 9bbdb1ff3ce846e275eb0040dcfdb199b2962c7b Mon Sep 17 00:00:00 2001 From: Florian Hines <syn@ronin.io> Date: Tue, 13 Sep 2022 10:59:01 -0500 Subject: [PATCH 24/26] mypy fix --- tests/test_basic_python_template.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_basic_python_template.py b/tests/test_basic_python_template.py index 816a407..aeb98b5 100644 --- a/tests/test_basic_python_template.py +++ b/tests/test_basic_python_template.py @@ -1,5 +1,5 @@ from basic_python_template import __version__ -def test_version(): +def test_version() -> None: assert __version__ == "0.1.0" From c6f82bdaac8da2028d658c0cd61aa24956f41a51 Mon Sep 17 00:00:00 2001 From: Florian Hines <syn@ronin.io> Date: Tue, 13 Sep 2022 11:07:13 -0500 Subject: [PATCH 25/26] Exclude tests from mypy checks --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 0554639..9996fec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,6 +46,7 @@ no_implicit_optional = true warn_return_any = true warn_unused_ignores = true show_error_codes = true +exclude = "tests" [build-system] requires = ["poetry-core"] From d1c5e714e64f6912b34e94fd222b13c4870bbe2d Mon Sep 17 00:00:00 2001 From: Florian Hines <syn@ronin.io> Date: Fri, 16 Sep 2022 09:57:21 -0500 Subject: [PATCH 26/26] Update pyproject.toml Co-authored-by: Will Da Silva <will@willdasilva.xyz> --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 9996fec..d4b3433 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,6 +48,9 @@ warn_unused_ignores = true show_error_codes = true exclude = "tests" +[tool.pytest.ini_options] +addopts = "-ra" + [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api"