Skip to content

Commit

Permalink
fix explicit version
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertCraigie committed Sep 27, 2024
1 parent 594b9a7 commit 349f424
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/pyright/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ def _should_warn_version(
# If this flag is set then the output must be machine parseable
return False

if os.environ.get('PYRIGHT_PYTHON_FORCE_VERSION'):
return False

if env_to_bool('PYRIGHT_PYTHON_IGNORE_WARNINGS', default=False):
return False

Expand Down
9 changes: 9 additions & 0 deletions tests/test_version_warning.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,19 @@ def test_ignore_warnings_env_var(monkeypatch: pytest.MonkeyPatch, env_value: str


def test_pylance_version_env_var(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr('pyright._utils.get_latest_version', lambda: '1.0.1')
monkeypatch.setattr('pyright._utils.__version__', '1.0.0')
monkeypatch.setenv('PYRIGHT_PYTHON_PYLANCE_VERSION', '1.0.0')
assert not _should_warn_version(args=(), quiet=None)


def test_force_version_env_var(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr('pyright._utils.get_latest_version', lambda: '1.0.1')
monkeypatch.setattr('pyright._utils.__version__', '1.0.0')
monkeypatch.setenv('PYRIGHT_PYTHON_FORCE_VERSION', '0.9.9')
assert not _should_warn_version(args=(), quiet=None)


def test_version_comparison(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr('pyright._utils.get_latest_version', lambda: '1.0.1')
monkeypatch.setattr('pyright._utils.__version__', '1.0.0')
Expand Down

0 comments on commit 349f424

Please sign in to comment.