Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,6 @@ repos:
- toml
- repo: local
hooks:
- id: run-pyre
name: run-pyre (expect this to take 30 seconds)
entry: python pyre_runner.py
types: [python]
language: python
log_file: ".git/pre-commit-pyre.log"
additional_dependencies: [pyre-check,mock]
- id: pytype
name: pytype (may take up to two minutes)
entry: sh -c "pytype >/dev/tty"
Expand Down
5 changes: 2 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,12 @@ This project uses `tox` to run the tests for different python versions. Intro:
> A comprehensive beginner's introduction to `tox`":_
> https://www.seanh.cc/2018/09/01/tox-tutorial/

`tox` runs `pytest`, `pylint` and static analysis using `mypy`, `pyre`, `pytype`, and `pyright`.
`tox` runs `pytest`, `pylint` and static analysis using `mypy`, `pytype`, and `pyright`.
Links:

- https://mypy.readthedocs.io/en/stable/
- https://microsoft.github.io/pyright/
- https://google.github.io/pytype/
- https://pyre-check.org/

With `tox`, developers can run the full test suite for Python 2.7 and 3.x.
The same test suite is used in GitHub CI:
Expand All @@ -78,7 +77,7 @@ Using pip-tools, you can extract the requirements and extras from `pyptoject.tom

```bash
PYTHON=python3.10
EXTRAS=.,test,mypy,pyre,pytype,tox
EXTRAS=.,test,mypy,pytype,tox
PFLAGS="--no-warn-conflicts"
$PYTHON -m pip install pip-tools==7.3.0
$PYTHON -m piptools compile --extra=$EXTRAS -o - pyproject.toml |
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The Continuous Integration Tests feature:
- Checking of the combined coverage against the diff to master: Fails if changes are not covered!
- Pylint report in the GitHub Action Summary page, with Warning and Error annotatios, even in the code review.
- Check that changes don't generate pylint warnings (if warning classes which are enabled in .pylintrc)
- Static analysis using `mypy`, `pyre` and `pytype`
- Static analysis using `mypy`, `pylint`, `pyright` and `pytype`

This enforces that any change (besides whitespace):

Expand Down Expand Up @@ -72,7 +72,6 @@ For the installation of the general development dependencies, visit [INSTALL.md]
- Test with `python2.7 -m pytest`
- Run `mypy` (without any arguments - The configuration is in `pyproject.toml`)
- Run `./pytype_runner.py`
- Run `./pyre_runner.py`
- Run `tox -e py36-lint` and fix any `Pylint` warnings
- Run `tox -e py310-covcombine-check` and fix any missing diff-coverage.
- Run `tox` for the full CI test suite
Expand All @@ -86,7 +85,7 @@ The list of `virtualenvs` configured in tox can be shown using this command: `to
$ tox -av
default environments:
py36-lint -> Run in a py36 virtualenv: Run pylint and fail on warnings remaining on lines in the diff to master
py311-pyre -> Run in a py311 virtualenv: Run pyre for static analyis, only passes using: tox -e py311-pyre
py311-pyright -> Run in a py311 virtualenv: Run pyright for static analyis
py38-pytype -> Run in a py38 virtualenv: Run pytype for static analyis, intro: https://youtu.be/abvW0mOrDiY
py310-covcombine-check -> Run in a py310 virtualenv: Generate combined coverage reports with py27-test coverage merged Run mypy for static analyis

Expand All @@ -100,7 +99,7 @@ test -> Run in a python virtualenv: Run pytest in this environ

If you have only one version of Python3, that works too. Use: `tox -e py<ver>-test`

## Static analysis using mypy, pyre, pyright and pytype
## Static analysis using mypy, pylint, pyright and pytype

The preconditions for using static analysis with `mypy` (which passes now but has
only a few type comments) and `pyright` are present now and `mypy` is enabled in `tox`
Expand Down
9 changes: 2 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ mypy = [
"types-six",
"types-toml",
]
# pyre introduced two false-postives recently, pin it to prevent further surprises:
pyre = [
"pyre-check == 0.9.21",
"pyre-extensions == 0.0.30",
]
pytype = [
"pandas",
"pytype",
Expand Down Expand Up @@ -200,8 +195,8 @@ include = ["xcp", "tests"]
pythonPlatform = "Linux"
pythonVersion = "3.11"
reportFunctionMemberAccess = true
reportGeneralTypeIssues = "warning"
reportOptionalMemberAccess = "warning"
reportGeneralTypeIssues = "error"
reportOptionalMemberAccess = "error"
reportPrivateUsage = true
reportPropertyTypeMismatch = true
reportUnnecessaryTypeIgnoreComment = false
Expand Down
62 changes: 0 additions & 62 deletions pyre_runner.py

This file was deleted.

4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
This module is run automatically by pytest to define and enable fixtures.
"""

# pyre-ignore-all-errors[21]
import warnings

import pytest # pyre does not find the module when run by tox -e py311-pyre
import pytest


@pytest.fixture(autouse=True)
def set_warnings():
Expand Down
1 change: 1 addition & 0 deletions tests/test_bootloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def _test_cfg(self, cfg):
stdout = subprocess.PIPE,
universal_newlines=True)

assert proc.stdout is not None # for pyright, to ensure it is valid
self.assertEqual(proc.stdout.read(), '''5a6,13
> if [ -s $prefix/grubenv ]; then
> load_env
Expand Down
1 change: 0 additions & 1 deletion tests/test_cpiofile.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# suppress false positive on pytest missing pytest.raises():
# pyre-ignore-all-errors[16]
"""
Test various modes of creating and extracting CpioFile using different compression
types, opening the archive as stream and as file, using pyfakefs as filesystem without
Expand Down
1 change: 0 additions & 1 deletion tests/test_httpaccessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def http_get_request_data(self, url, read_file, error_handler):

def assert_http_get_request_data(self, url, read_file, error_handler):
# type:(str, str, ErrorHandler) -> HTTPAccessor
# pyre-ignore[23]: silence false positive
with self.http_get_request_data(url, read_file, error_handler) as (httpaccessor, ref):
http_accessor_filehandle = httpaccessor.openAddress(read_file)
if sys.version_info >= (3, 0):
Expand Down
1 change: 1 addition & 0 deletions tests/test_xmlunwrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def setUp(self):
self.top_el = xmldoc.documentElement

def test(self):
assert self.top_el is not None # This test requires that top_el is not None
self.assertEqual(self.top_el.tagName, "installation")

self.assertEqual([getText(el)
Expand Down
25 changes: 12 additions & 13 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# 1. python 2.7 and 3.10 coverage test for changed, but not covered lines and mypy check
# 2. python 3.6 test and pylint warnings from changed lines
# 3. pytype (needs Python 3.8 for best results)
# 4. pyre and pyright checks, pytest test report as markdown for GitHub Actions summary
envlist = py38-covcombine-check, py311-lint-test, py310-pytype, py311-pyre-mdreport
# 4. pyright checks, pytest test report as markdown for GitHub Actions summary
envlist = py38-covcombine-check, py311-lint-test, py310-pytype, py311-pyright-mdreport
isolated_build = true
skip_missing_interpreters = true
requires =
Expand Down Expand Up @@ -42,25 +42,23 @@ description = Run in a {basepython} virtualenv:
lint: {[lint]description}
mdreport: Make a test report (which is shown in the GitHub Actions Summary Page)
test: {[test]description}
# https://pypi.org/project/pyre-check/ pyre intro: https://youtu.be/0FSXS5kw2m4
pyre: Run pyre for static analyis, only passes using: tox -e py311-pyre
# See https://microsoft.github.io/pyright/#/configuration for more in pyright
pyright: Run pyright for static analyis
check: Run mypy for static analyis
pytype: Run pytype for static analyis, intro: https://youtu.be/abvW0mOrDiY
# checkers(mypy) need the pytest dependices as well:
extras =
{check,pytype}: {[check]extras}
{cov,covcp,covcombine,fox,check,lint,test,pytype,pyre,mdreport}: {[test]extras}
{cov,covcp,covcombine,fox}: {[cov]extras}
{cov,covcp,covcombine,fox,check,lint,test,pytype,pyright,mdreport}: {[test]extras}
{cov,covcp,covcombine,fox}: {[cov]extras}
deps =
mdreport: pytest-md-report
{py27-test,py27-cov}: pyftpdlib
{py27-test,py27-cov}: pylint
{cov,covcp,covcombine,fox}: coverage[toml]
{cov,covcp,covcombine,fox}: diff-cover
{lint,fox}: {[lint]deps}
pyre: pyre-check
pyre: pyre-extensions
pyre: pyright
pyright: pyright
pytype: {[pytype]deps}
allowlist_externals =
{cov,covcp,covcombine,fox,check,lint,test,mdreport}: echo
Expand All @@ -81,7 +79,6 @@ passenv =
covcp: HOME
check: MYPY_FORCE_COLOR
check: MYPY_FORCE_TERMINAL_WIDTH
pyre: PYRE_TYPESHED
{fox,check,pytype}: TERM
fox: DISPLAY
fox: XAUTHORITY
Expand All @@ -104,7 +101,7 @@ setenv =
{[cov]setenv}
commands =
lint: {[lint]commands}
pyre: {[pyre]commands}
pyright: {[pyright]commands}
check: {[check]commands}
pytype: {[pytype]commands}
{cov,covcp,covcombine,check,fox,test,mdreport}: {[test]commands}
Expand Down Expand Up @@ -200,9 +197,11 @@ commands =
ignore = W191,W293,W504,E101,E126,E127,E201,E202,E203,E221,E222,E226,E227,E241,E251,E261,E262,E265,E301,E302,E303,E305,E722,W391,E401,E402,E741
max-line-length = 129

[pyre]
[pyright]
commands =
-pyright
pyright --version
# To make pyright checks optional, change the next line to '-pyright':
pyright

[pytype]
deps = pytype
Expand Down
1 change: 0 additions & 1 deletion xcp/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"""accessor - provide common interface to access methods"""

import errno
# pyre-ignore-all-errors[6,16]
import ftplib
import io
import os
Expand Down
3 changes: 1 addition & 2 deletions xcp/bootloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

import xcp.cmd

# pyre-ignore-all-errors[21]
try: # xenserver-release.rpm puts a branding.py into our xcp installation directory:
from xcp import branding # type:ignore[attr-defined] # pytype: disable=import-error
except ImportError: # For CI, use stubs/branding.py (./stubs is added to pythonpath)
Expand Down Expand Up @@ -61,7 +60,7 @@ def __init__(self, hypervisor, hypervisor_args, kernel, kernel_args,
self.initrd = initrd
self.title = title
self.root = root
self.entry_format = None
self.entry_format = None # type: Grub2Format | None

def getHypervisorArgs(self):
return re.findall(r'\S[^ "]*(?:"[^"]*")?\S*', self.hypervisor_args)
Expand Down
2 changes: 0 additions & 2 deletions xcp/cpiofile.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
Derived from Lars Gustäbel's tarfile.py
"""
from __future__ import print_function
# pyre is not as good as other static analysis tools in inferring the correct types:
# pyre-ignore-all-errors[6,16]

__version__ = "0.1"
__author__ = "Simon Rowe"
Expand Down
Loading