Skip to main content

A language server / linter for the Tryton framework

Project description

Tryton Analyzer

What's this

tryton-analyzer is a dedicated Language Server / Linter to assist developers using the tryton framework.

Due to how the framework operates (most notably the runtime inheritance), the standard Python tooling is not as useful as it can / should be. This means that most errors that could be detected by a linter (unknown attributes, etc.) are not, which leads to runtime / production errors.

Disclaimer

This is just a hobby project for now, and though it is already useful, it requires a patched trytond (on version 6.8).

It is only tested on Neovim, though it should work on other editors supporting the Language Server Protocol.

How does it work

It uses pygls to handle the language server protocol, libcst to parse the sources, and a patched trytond to be able to load modules without any database whatsoever.

The language server itself spawns and requests informations from separate trytond processes to be able to survive Syntax Errors in the source code.

What can it do

Focus so far has been on basic things:

  • Detecting unkown attributes (python / xml)
  • Completion
  • Support of extras_depend to distinguish available models / fields even in a given module

Model detection is done through parsing of the syntax tree using libsct. It relies on:

  • self / cls for obvious reasons
  • Special function parameters (for instance, the second argument of validate will always be a list of records)
  • Parsing of Pool().get calls
  • Custom type annotations: def my_function(self, invoices: Records["account.invoice"])

What will it do

I have a lot of things I would like to do next:

  • Return type annotations
  • Extract more informations from the tryton pool (identify getters & co to automatically assign types)
  • Domain / state parsing
  • Jump to definition
  • Better information for fields during completion
  • Find usages of fields / methods (though this one will probably be difficult and need some sort of persistent caching)

Give it a try

pip install tryton-analyzer, and setup your development environment to use the patched trytond rather than the default one.

On the client side, use lspconfig for Neovim:

  local lspconfig = require("lspconfig")
  local configs = require'lspconfig.configs'
  if not configs.tryton_analyzer then
    configs.tryton_analyzer = {
      default_config = {
        cmd = { vim.fn.expand('~/Personal/projects/coog/tryton-analyzer/launcher') },
        filetypes = {'python.trpy', 'xml.trxml'},
        root_dir = lspconfig.util.root_pattern(".git"),
        settings = {},
      };
    }
  end
  lspconfig.tryton_analyzer.setup{

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tryton_analyzer-0.0.5.tar.gz (20.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tryton_analyzer-0.0.5-py3-none-any.whl (21.8 kB view details)

Uploaded Python 3

File details

Details for the file tryton_analyzer-0.0.5.tar.gz.

File metadata

  • Download URL: tryton_analyzer-0.0.5.tar.gz
  • Upload date:
  • Size: 20.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.1 Linux/6.2.0-39-generic

File hashes

Hashes for tryton_analyzer-0.0.5.tar.gz
Algorithm Hash digest
SHA256 e0babdfbeab6e6f6e1a4aaff3bd99adb136a76ecb1806f5fddb00f2f7fa4c2d2
MD5 19f76db7038216b57d7b8b8092573167
BLAKE2b-256 d8d25fd510b1563d952df34047253ff24da54d3fd14e5bfeb72b682d9890b8b9

See more details on using hashes here.

File details

Details for the file tryton_analyzer-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: tryton_analyzer-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 21.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.1 Linux/6.2.0-39-generic

File hashes

Hashes for tryton_analyzer-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 f48e7043ca9dde4977e114078da87ad4d0a3e3bb80c2fe52aa6a069be378ea33
MD5 2747707ebf50c4ce89b24671c760572f
BLAKE2b-256 42f4d83e50e572c296dfbaf6ded9fcf8cf874e0ea6ef382408d45551d25170bc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page