Skip to content

Document version/system/implementation checks that tools might want to support #17

@o11c

Description

@o11c

A tool takes as input a python version, host system, python implementation, and body of python code, and returns a set of errors. Some tools may also support querying the type of an expression (e.g. for autocompletion of its attributes in an IDE).

How many and how finely it supports the platform checks, and whether it allows running checks for platforms other than the one it is currently running (simultaneously or in a separate run), is a QoI issue - this document nearly. However, tools should not make it impossible to check Windows-specific code from a Linux host.

At the very least, most tools will want to support python2 vs python3 detection.

Here's my list of branches that should be followed:

  • assert and if statements with comparisons (==, !=, <, >, <=, >=; possibly chained like x < y < z), and and, not, and or expressions containing only comparisons, which contain only literals (of type str, int, or tuple of literals) and the following:
    • platform.python_version()
    • platform.python_version_tuple()
    • sys.version
    • sys.version_info
    • indexing and slices of the above
    • sys.hexversion
    • platform.python_implementation()
    • platform.system()
    • sys.platform maybe? (icky for e.g. linux2 vs linux)
    • Some way to specify that a value exported really is supposed to be constant.
      • "Anything that is not initialized to ..." would require changing many stubs that currently use x = ('', 0) as a short form of x = ... # type: Tuple[str, int].
      • Use this to implement a six stub via the above.
  • else and elif branches following the above (not that elif need not have such an expression)
  • Other:
    • if string_literal [not] in sys.modules maybe? Needs justification.
    • try ... except ImportError
    • try ... except AttributeError where the object is a module.
    • try ... except NameError for builtins e.g. unicode and long.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions