Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertCraigie committed Sep 27, 2024
1 parent 349f424 commit e75e26d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/pyright/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ 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 All @@ -127,6 +124,10 @@ def _should_warn_version(
if os.environ.get('PYRIGHT_PYTHON_PYLANCE_VERSION'):
return False

force_version = os.environ.get('PYRIGHT_PYTHON_FORCE_VERSION')
if force_version and force_version != __pyright_version__:
return True

# NOTE: there is an edge case here where a new pyright version has been released
# but we haven't made a new pyright-python release yet and the user has set
# PYRIGHT_PYTHON_FORCE_VERSION to the new pyright version.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_version_warning.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ 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)
assert _should_warn_version(args=(), quiet=None)


def test_version_comparison(monkeypatch: pytest.MonkeyPatch) -> None:
Expand Down

0 comments on commit e75e26d

Please sign in to comment.