Skip to content

Repository files navigation

Web2py Autocompletion

Web2py — Autocompletion & Navigation

The VS Code extension that web2py never had.
Autocomplete · Hover docs · Go to Definition · Typo detection
One index per application. Zero configuration.

version web2py 2.x MIT


Why this exists

web2py injects db, session, request, response, auth, T, and hundreds of other names into every controller and model at runtime. No editor understands this — Pylance flags everything red, autocomplete offers nothing, and Go to Definition doesn't work.

This extension fixes all of it. It indexes your web2py project the way web2py itself sees it, and gives you the IDE experience every other framework gets out of the box.


Features

Autocomplete

You type You get
db. Every table in the current application
db.employee. Fields with type, requires, and default value
db[t][f]. Full Field API — belongs, lower, cast, contains, …
Field( Kwarg completion — multiline-aware, filters already-used kwargs
session. Every key assigned anywhere in the app, with file and line
request.vars. Vars keys used across the app
IS_IN_ All validators with signature and usage example
app_settings. Keys from model settings containers
TwoDimensionalView. Methods and attributes with full parameter list
Field, DAL, Rows 325+ pydal/gluon names with signatures, straight from the source

Every completion item shows the signature and a one-line summary beside the label — you see what something does without opening the docs popup.

Go to Definition (F12 / Ctrl+Click)

Click on Jumps to
A model function or class Its definition in models/
A table name The define_table call
A validator or HTML helper The line in pydal/validators.py or gluon/html.py
A settings key The file and line where the key was assigned
A controller variable Its assignment in the models
A controller string value The controller file
Any pydal/gluon name The source file

Hover documentation

Hover any name for its full signature, all parameters, and the complete docstring — inherited docs included. Works across model code, pydal, gluon, validators, HTML helpers, and settings.

Diagnostics

  • Name typos in red — Fiel → did you mean Field?
  • Kwarg typostyp=type
  • Syntax errors via Python's ast.parse
  • Ctrl+. quick fixes — one keypress correction
  • Star-import files are skipped — no false positives

Pylance integration

Automatically suppresses reportUndefinedVariable for web2py's injected globals. No more yellow underlines on db, session, auth, or T.


Install from release

  1. Download the latest .vsix from Releases
  2. Open VS Code → Extensions panel → menu → Install from VSIX…
  3. Select the downloaded .vsix file
  4. Open your web2py folder (the one containing applications/) as workspace
  5. Reload the window

Build from source

git clone https://github.com/IbraDevx/Web2py-AutoComplete.git
cd Web2py-AutoComplete

npm install
npx tsc -p ./
npx vsce package

This produces web2py-intern-tools-<version>.vsix. Install it with:

code --install-extension web2py-intern-tools-0.13.0.vsix

Or via VS Code: Extensions → Install from VSIX…


Coverage

The extension covers every name available at runtime in a web2py application.

Source Names Method
list_globals.py 130+ dir() over 21 gluon modules at startup
list_api.py 325+ AST parse of pydal/gluon source — no imports needed
list_members.py session, request, response, Field members inspect on live objects
Indexer tables, fields, model functions, settings containers Static analysis of your code

100% of what Python's dir() returns is known to the extension, with signatures and documentation.


Commands

Command What it does
Rebuild Index Re-indexes all applications in the workspace
Scan All Files for Errors Runs diagnostics across every .py file
Show Index for This File Prints every global, container, key and class member — debug tool for missing completions

All accessible via Ctrl+Shift+P.


Architecture

src/
  extension.ts      activation, completion, hover, Go to Definition
  parser.ts         tables, fields, functions, classes, settings containers
  indexer.ts        one AppIndex per application, merges models + controllers + modules
  diagnostics.ts    name/kwarg typo detection, syntax errors
  kwargcomplete.ts  Field() / define_table() kwarg completion
  quickfix.ts       Ctrl+. code actions

scripts/
  list_globals.py   dir() over gluon → runtime names with signatures and docs
  list_api.py       ast walk over pydal/gluon source → every function/class/method
  list_members.py   members of session/request/response/Field via inspect
  generate_stubs.py .pyi stub for Pylance

See DEVELOPMENT.md for the full developer guide.


Contributing

Issues and PRs welcome. Run the test suite before submitting:

node test-fixture/test-full-diagnostics.js
node test-fixture/test-precision.js
node test-fixture/test-functions.js
node test-fixture/test-members.js
node test-fixture/test-global-objects.js
node test-fixture/test-class-members.js
node test-fixture/test-api-extract.js

License

MIT — see LICENSE.


Developed by Ibrahem Darwish

Releases

Packages

Contributors

Languages