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 = { 'tryton-ls' },
        filetypes = {'python', 'xml'},
        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.6.tar.gz (20.4 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.6-py3-none-any.whl (21.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tryton_analyzer-0.0.6.tar.gz
  • Upload date:
  • Size: 20.4 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.6.tar.gz
Algorithm Hash digest
SHA256 54d6a55a4eca2d759329841aba9f3236a1d13ff653a03f3fd0830ad4c975fbf9
MD5 ed3a7b5eafaea1489a9fcc3d31f964c3
BLAKE2b-256 641b60612595d24bd93609aa060a013d723f9870644c337acfbf51f7aeef9a86

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tryton_analyzer-0.0.6-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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 09fc6ac7393ed2b9efab1d01ac2dc71e12fa217258a0214ba0b04f391f8fc870
MD5 9fc71277598e3cb01cb715e6d99f1021
BLAKE2b-256 8c51d8775f73a8f3c4a709ad0ef179409a34d764492f07d2c2c67d95d9e5040a

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