Proposal to add "tox" as a standard package - entry point for testing and linting

94 Aufrufe
Direkt zur ersten ungelesenen Nachricht

Matthias Koeppe

ungelesen,
07.09.2020, 17:18:3407.09.20
an sage-devel
tox (https://tox.readthedocs.io/en/latest/) is a popular package that is used by a large number of Python projects as the standard entry point for testing and linting.

Sage 9.1 started to use tox for portability testing of the Sage distribution (https://doc.sagemath.org/html/en/developer/portability_testing.html#automatic-docker-based-build-testing-using-tox), which requires an installation of tox in the system python.

In several recent tickets, we have added a tox configuration (src/tox.ini) for the (more typical) use of tox for testing and linting of the Sage library. (See https://trac.sagemath.org/ticket/30453 and dependencies.)

This provides an entry point for various testing/linting methods that is more idiomatic from the viewpoint of the Python community.

1. The commands "sage -t", "sage -coverage", "sage -coverageall", and "sage -startuptime" are repackaged as "sage --tox" follows:

  --tox [options] <files|dirs> -- general entry point for testing
                                  and linting of the Sage library
     -e <envlist>     -- run specific test environments (default: run all)
        doctest          -- run the Sage doctester 
                            (same as "sage -t")
        coverage         -- give information about doctest coverage of files 
                            (same as "sage --coverage[all]")
        startuptime      -- display how long each component of Sage takes to start up 
                            (same as "sage --startuptime")

2. Three new linting methods are added:

        pycodestyle      -- check against the Python style conventions of PEP8
        relint           -- check whether some forbidden patterns appear 
                            (includes all patchbot pattern-exclusion plugins)
        codespell        -- check for misspelled words in source code


This functionality is available after installing the optional "tox" package using "sage -i tox" (or having tox available in the system).

I propose to make "tox" a standard package of the Sage distribution so that this functionality becomes available by default.

By convention, this requires a vote here on sage-devel.


Eric Gourgoulhon

ungelesen,
07.09.2020, 17:44:0207.09.20
an sage-devel
+1
Eric.

Dima Pasechnik

ungelesen,
07.09.2020, 18:04:2707.09.20
an sage-devel
+1

--
You received this message because you are subscribed to the Google Groups "sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/aea49c5b-fca9-4195-a890-f5ed7613af0bo%40googlegroups.com.

Samuel Lelievre

ungelesen,
07.09.2020, 19:26:5707.09.20
an sage-devel
+1

Travis Scrimshaw

ungelesen,
07.09.2020, 22:08:4507.09.20
an sage-devel
+1

Matthias Koeppe

ungelesen,
09.09.2020, 13:05:4409.09.20
an sage-devel
On Monday, September 7, 2020 at 2:18:34 PM UTC-7, Matthias Koeppe wrote:
tox (https://tox.readthedocs.io/en/latest/) is a popular package that is used by a large number of Python projects as the standard entry point for testing and linting.
[...] 
I propose to make "tox" a standard package of the Sage distribution so that this functionality becomes available by default.

By convention, this requires a vote here on sage-devel.


Thanks everyone. This is now https://trac.sagemath.org/ticket/30416, needs review


jplab

ungelesen,
06.10.2020, 10:34:4106.10.20
an sage-devel
Hi!

This looks like a great new feature! I discovered it by surprise when the command "pep8 -v some_file.py" was not returning anything anymore, while typically it returns hundreds of lines...

Looking a bit around, I guess that one should add a few of the typical PEP8 errors in tox.ini? Does that make sense? It seems that the lines responsible for that are:

[pycodestyle]                                                                                                                                                                                                 
# Check for the following issues:
# E401: multiple imports on one line
# E701: multiple statements on one line (colon)
# E702: multiple statements on one line (semicolon)
# W605: invalid escape sequence ‘x’
# See https://pycodestyle.pycqa.org/en/latest/intro.html#error-codes
select = E401,E701,E702,W605
max-line-length = 160

I'm thinking about the usual "Empty line contains whitespaces", and similar... should they all be listed here?

If I understood correctly, this likely affects everyone using pep8 while coding and linting... What should be the Sage-9.2-method/command to get something that looks like the good old "pep8 -v" output?

Matthias Koeppe

ungelesen,
06.10.2020, 12:29:3906.10.20
an sage-devel
On Tuesday, October 6, 2020 at 7:34:41 AM UTC-7, jplab wrote:
This looks like a great new feature! I discovered it by surprise when the command "pep8 -v some_file.py" was not returning anything anymore, while typically it returns hundreds of lines...

Looking a bit around, I guess that one should add a few of the typical PEP8 errors in tox.ini? Does that make sense? It seems that the lines responsible for that are:

[pycodestyle]                                                                                                                                                                                                 
# Check for the following issues:
# E401: multiple imports on one line
# E701: multiple statements on one line (colon)
# E702: multiple statements on one line (semicolon)
# W605: invalid escape sequence ‘x’
# See https://pycodestyle.pycqa.org/en/latest/intro.html#error-codes
select = E401,E701,E702,W605
max-line-length = 160

I'm thinking about the usual "Empty line contains whitespaces", and similar... should they all be listed here?

If I understood correctly, this likely affects everyone using pep8 while coding and linting... What should be the Sage-9.2-method/command to get something that looks like the good old "pep8 -v" output?

The configuration set in tox.ini is the same as the one used by the patchbot.

The command

./sage --tox -e pycodestyle -- --help

shows the options available for pycodestyle. (Note "--", to separate from tox options.) For example, you could use:

./sage --tox -v -e pycodestyle -- --select=E121,E123,E126,E226,E24,E704,W503,W504 src/sage/geometry

If we wanted, we could add a variant (perhaps called "./sage --tox -e pycodestyle-strict") that activates a stricter set of options than what the patchbot uses.




 
Allen antworten
Antwort an Autor
Weiterleiten
0 neue Nachrichten