python / python/mypy

`test_update_data` fails when `-x` is in `PYTEST_ADDOPTS`

Open
#16,265 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug topic-tests
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

Bug Report

When I run tests for mypy-1.6.0 and -x is in PYTEST_ADDOPTS then test_update_data fails.

To Reproduce

The following command fails:

PYTEST_ADDOPTS="-x" PATH=/usr/gcc/10/bin:$PATH /usr/bin/tox --recreate -e py39 -- mypy/test/meta/test_update_data.py -vv

Expected Behavior

Interestingly, the following passes (please note -x at the end of line):

PYTEST_ADDOPTS="" PATH=/usr/gcc/10/bin:$PATH /usr/bin/tox --recreate -e py39 -- mypy/test/meta/test_update_data.py -vv -x

Actual Behavior

The relevant part of the output:

E           [case testMissingMultiline]
E           s: str = 42;  i: int = 'foo'  # E: Incompatible types in assignment (expression has type "int", variable has type "str") \
E                                         # E: Incompatible types in assignment (expression has type "str", variable has type "int")
E
E           [case testExtraneous]
E         - s: str = 'foo'
E         + s: str = 'foo'  # E: wrong error
E
E           [case testExtraneousMultiline]
E         - s: str = 'foo'
E         + s: str = 'foo'  # E: foo                             # E: bar
E
E           [case testExtraneousMultilineNonError]
E         - s: str = 'foo'
E         + s: str = 'foo'  # W: foo                             # N: bar
E
E           [case testOutCorrect]
E           s: str = 42
E           [out]
E           main:1: error: Incompatible types in assignment (expression has type "int", variable has type "str")
E
E           [case testOutWrong]
E           s: str = 42
E           [out]
E         - main:1: error: Incompatible types in assignment (expression has type "int", variable has type "str")
E         + main:1: error: foobar
E
E           [case testOutWrongIncremental]
E           s: str = 42
E           [out]
E         - main:1: error: Incompatible types in assignment (expression has type "int", variable has type "str")
E         + main:1: error: foobar
E           [out2]
E         - main:1: error: Incompatible types in assignment (expression has type "int", variable has type "str")
E         + main:1: error: foobar
E
E           [case testWrongMultipleFiles]
E           import a, b
E         - s: str = 42  # E: Incompatible types in assignment (expression has type "int", variable has type "str")
E         + s: str = 42  # E: foo
E           [file a.py]
E         - s1: str = 42  # E: Incompatible types in assignment (expression has type "int", variable has type "str")
E         + s1: str = 42  # E: bar
E           [file b.py]
E         - s2: str = 43  # E: Incompatible types in assignment (expression has type "int", variable has type "str")
E         + s2: str = 43  # E: baz
E           [builtins fixtures/list.pyi]

Your Environment

  • Mypy version used: 1.6.0
  • Mypy command-line flags: N/A
  • Mypy configuration options from mypy.ini (and other config files): N/A
  • Python version used: 3.9.16

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the reported tox command against mypy/test/meta/test_update_data.py, then compare it with the passing command where -x is supplied at the end. Inspect how this test handles pytest options and update its behavior so the test passes with -x in PYTEST_ADDOPTS as well as on the command line.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.