Package: invoke-common-tasks
Invoke Common TasksSome common tasks for PyInvoke to bootstrap your code quality and testing workflows.Invoke Common TasksGetting StartedInvoke SetupThe Tasksbuildformatlinttypechecktest (and coverage)ciinit-configTODORoadmapAll TogetherContributingDevelopmentResourcesPrior ArtGetting Startedpipinstallinvoke-common-tasks# Orpoetryadd-Dinvoke-common-tasks# With Extraspipinstallinvoke-common-tasks[all]# Orpoetryadd--groupdevinvoke-common-tasks[all]invoke-common-tasksdefines a fewextras, where you can also install the tooling to go with each task.
By default wedo notinstall the tools that these tasks call, since you could have different pinned versions than what we specify.However, you can installallof them or distinct subsets:format->black,isortlint->flake8,flake8-docstringstypecheck->mypytest->pytest,pytest-cov,coverage[toml]So you can specify the following if you only wantformatandtest:pipinstallinvoke-common-tasks[format,test]Alltaskswill still be available but we won't install associated tooling.Invoke Setuptasks.pyfrominvoke_common_tasksimport*# noqaOnce yourtasks.pyis setup like thisinvokewill have the extra commands:λinvoke--list
Availabletasks:buildBuildwheel.ciRunlintingandtestsuiteforContinuousIntegration.formatAutoformatcodeforcodestyle.init-configSetupdefaultconfigurationfordevelopmenttooling.lintLintingandstylechecking.testRuntestsuite.typecheckRuntypecheckingtooling.You can also initialise default configuration for each tool by running the following:invokeinit-config--allMore details in theinit-configsection.The TasksbuildAssuming you are usingpoetrythis will build a wheel (and only a wheel).formatThis will apply code formatting toolsblackandisort.These are only triggers for these commands, the specifics of configuration are up to you.Recommended configuration in yourpyproject.toml:[tool.black]line-length=120[tool.isort]profile="black"multi_line_output=3import_heading_stdlib="Standard Library"import_heading_firstparty="Our Libraries"import_heading_thirdparty="Third Party"lintThis will run checks forblack,isortandflake8.Up to you to specify your preferences of plugins forflake8and its configuration.Recommended configuration in.flake8:[flake8]exclude=venv,dist,.venvselect=ANN,B,B9,BLK,C,D,DAR,E,F,I,S,Wignore=E203,E501,W503,D100,D104per-file-ignores=tests/*:D103,S101max-line-length=120max-complexity=10import-order-style=googledocstring-convention=googleRecommendedflake8plugins:flake8-docstringsMoreflake8plugins:https://github.com/DmytroLitvinov/awesome-flake8-extensionstypecheckSimply runsmypy ..Recommended configuration to add to yourpyproject.toml[tool.mypy]pretty=trueshow_error_codes=trueshow_column_numbers=trueshow_error_context=trueexclude=['tests/','tasks\.py']follow_imports='silent'ignore_missing_imports=true# Work your way up to these:disallow_incomplete_defs=true# disallow_untyped_defs = true# disallow-untyped-calls = true# strict = truetest (and coverage)This will simply runpython3 -m pytest. This is important to run as a module instead ofpytestsince it resolves
a lot of import issues.You can simply not import this task if you prefer something else. But all config and plugins are left flexible for your own desires, this simply triggers the entrypoint.Recommended configuration inpyproject.toml:[tool.pytest.ini_options]minversion="6.0"addopts="-s -vvv --color=yes --cov=. --no-cov-on-fail"[tool.coverage.run]omit=["tests/*","**/__init__.py","tasks.py"]branch=trueAssuming you also installpytest-covandcoverage[toml].Recommendedpytestplugins:pytest-xdist- Run tests in parallel using maximum cpu corespytest-randomly- Run tests in random order each time to detect tests with unintentional dependencies to each other that should be isolated. Each run prints out the seed if you need to reproduce an exact seeded run.pytest-cov- It is recommended to run coverage from thepytestplugin.List of otherpytestplugins:https://docs.pytest.org/en/latest/reference/plugin_list.htmlciThis is a task with no commands but chains togetherlint,typecheckandtest.init-configExperimental: This feature is still in a pre-release state.Each of the above commands came with some recommended configuration.
This command attempts to automate setting up even that part in yourpyproject.tomland.flake8files.λinvokeinit-config--help
Usage:inv[oke][--core-opts]init-config[--options][othertaskshere...]Docstring:Setupdefaultconfigurationfordevelopmenttooling.

Options:-a,--all-f,--format-l,--lint-t,--test-y,--typecheckTODOAdd task for auto generation of Sphinx Docs.Add typechecking support to roottasks.pyfile now that Invoke v2+ is released.RoadmapThis project will get marked as a stable v1.0 once the above TODO features are ticked off and this has seen at least 6 months in the wild in production.All TogetherOnce all the tasks are imported, you can create a custom task as your default task with runs a few tasks chained together.frominvokeimporttaskfrominvoke_common_tasksimport*@task(pre=[format,lint,typecheck,test],default=True)defall(c):"""Default development loop."""...You will notice a few things here:The method has no implementation...We are chaining a series of@tasks in thepre=[...]argumentThedefault=Trueon this root tasks means we could run eitherinvoke allor simplyinvoke.How cool is that?ContributingAt all times, you have the power to fork this project, make changes as you see fit and then:pipinstallhttps://github.com/user/repository/archive/branch.zipStackoverflow: pip install from github branchThat way you can run from your own custom fork in the interim or even in-house your work and simply use this project as a starting point. That is totally ok.However if you would like to contribute your changes back, then open a Pull Request "across forks".Once your changes are merged and published you can revert to the canonical version ofpip installing this package.If you're not sure how to make changes or if you should sink the time and effort, then open an Issue instead and we can have a chat to triage the issue.Developmentgitclonehttps://github.com/neozenith/invoke-common-taskscdinvoke-common-tasks
poetryshell# This will not install the dev dependencies which are optional when a consumer uses the project but are actually needed for development of this librarypoetryinstall--all-extrasResourcespyinvokePrior Arthttps://github.com/Smile-SA/invoke-sphinxhttps://github.com/Dashlane/dbt-invokehttps://invocations.readthedocs.io/en/latest/index.html