Package: devshell
devshellView API documentationdevshell is my python development workflow helper.Navigating Code TreesThere's normal basic shell navigation with cd, ls, pwd, and then there are python versions of those for navigating through a code tree: pcd, pls, ppwd.What is a code tree? It is the following types of code blocks:PackageModuleClassFunction/Method/Coroutine$cd~/projects/statopy
$ls
LICENSE__pycache__statopy.py
$python3-mdevshell
Startingdevshellcommandlineinterface...
devshellversion0.0.3
Welcometodevshell.Typehelpor?tolistcommands.Startalinewith!toexecuteashellcommandinasub-shell(doesnotretainenvironmentalvariables).(devshell)$If a package or module in your current working directory (the normal type affected by cd and reported with pwd), then those will show up when you type pls.
You can enter your "python location" into it via pcd and check your current python location with ppwd.Autocompletion works as usual for cd and ls.
For the python versions, autocompletion shows you what your options are in terms of child code blocks (e.g. methods in the current class).(devshell)$plsstatopymoduledirectory(devshell)$pcdstatopy(devshell)$plsScalarProbModelclassdirectoryScalarRegressionclassdirectoryScalarStatsclassdirectoryVectorStatsclassdirectory(devshell)$pcdScalarStats(devshell)$pls__add__functionnon-directory__init__functionnon-directory__setattr__functionnon-directoryconsumefunctionnon-directoryupdatefunctionnon-directory(devshell)$ppwd/statopy.ScalarStats(class)(devshell)$CommandsThat's nice, but what can you do besides inspecting what code blocks exist?Type help to see a list of commands. Calling programs with arguments/redirection works as usual.(devshell)$helpDocumentedcommands(typehelp<topic>):========================================EOFdeactivateedithelppcdpytestrestartvenv
activatedebugeditviminteractivepippythonrmcddocexitlsplsqrmtreecoveragedoctestgrepmkdirppwdquitruncpdoctestifyhmvpwdreadsourceDoctestsIf you navigate to a code block, you can examine the docstring and function definition using thedoccommand.
You can run any doctests present in that code block by using thedoctestcommand.
You can calldoctestifyto enter into an interactive session with the module's contents imported. All input and output in this session is recorded, and when the session is closed via CTRL+D, the input/output is appended to the docstring of the current code block as an additional set of doctests.doctestify resumewill open the interactive session and execute all existing doctest commands in the current docstring before turning interactive control over to you. This is useful if you are tweaking code while repeatedly running some test. You don't have to rewrite any setup code multiple times, just use what is in the docstring.Pytest/Coveragepytestandcoverage- pretty self-explanatory. Coverage runs pytest and doctests and produces a combined report.Debuggingdebug(5,'hello',[1,2,3])takes the current function or class and calls it like <current_func>(5,'hello',[1,2,3]), entering debug mode on the first line. You can put any python calling expression and as many arguments as you want.
If the current code block is a module or package, it requires no inputs, just calldebug. For a module, it will enter debug mode on the first line of the module. For a package, it will enter debug mode for the first line of the __init__.py file.Looking at codegrep pattern [OPTIONS]runs a grep-like function that is filtered on the current code block.editvimopens vim to the line corresponding to the currently targeted code block.sourceopens a paginated view with the text of the current code block (excludes the rest of the file).