Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable pylint print statement flag + fix venv detection #954

Merged
merged 112 commits into from
Mar 6, 2018
Merged

Disable pylint print statement flag + fix venv detection #954

merged 112 commits into from
Mar 6, 2018

Conversation

MikhailArkhipov
Copy link

@MikhailArkhipov MikhailArkhipov commented Mar 5, 2018

Fixes #722
Properly detects venv
Added tests

const output = await this.processService.exec(pythonPath, ['-c', 'import sys;print(hasattr(sys, "real_prefix"))']);
// hasattr(sys, 'real_prefix') works for virtualenv while
// '(hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix))' works for venv
const code = 'import sys\nif hasattr(sys, "real_prefix"):\n print("virtualenv")\nif hasattr(sys, "base_prefix") and sys.base_prefix != sys.prefix:\n print("venv")';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should that be an elif for the second clause?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prob doesn't matter, first won't be executed if the second is true I assume.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better safe than sorry, so I just made the change directly in the PR. 😄

// hasattr(sys, 'real_prefix') works for virtualenv while
// '(hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix))' works for venv
const code = 'import sys\nif hasattr(sys, "real_prefix"):\n print("virtualenv")\nif hasattr(sys, "base_prefix") and sys.base_prefix != sys.prefix:\n print("venv")';
const output = await this.processService.exec(pythonPath, ['-c', code]);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Time to change this to iif

@codecov
Copy link

codecov bot commented Mar 5, 2018

Codecov Report

Merging #954 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #954      +/-   ##
==========================================
- Coverage   64.01%   64.01%   -0.01%     
==========================================
  Files         260      260              
  Lines       12028    12027       -1     
  Branches     2131     2130       -1     
==========================================
- Hits         7700     7699       -1     
  Misses       4319     4319              
  Partials        9        9
Impacted Files Coverage Δ
src/client/linters/pylint.ts 98.33% <ø> (ø) ⬆️
src/client/interpreter/virtualEnvs/index.ts 100% <100%> (ø) ⬆️
src/client/linters/baseLinter.ts 85.41% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0f39773...bd2e936. Read the comment docs.

@MikhailArkhipov MikhailArkhipov merged commit 77f3612 into microsoft:master Mar 6, 2018
brettcannon added a commit to brettcannon/vscode-python that referenced this pull request Mar 7, 2018
Due to a bug in Pylint where specifying `E` as enabled checks flips on `--py3k`, we need to explicitly list all `E` checkers to explicitly avoid (at least) print-statement which throws false-positives for folks not porting to Python 3.

Closes microsoft#722 by partially reverting microsoft#954
brettcannon added a commit that referenced this pull request Mar 7, 2018
Due to a bug in Pylint where specifying `E` as enabled checks flips on `--py3k`, we need to explicitly list all `E` checkers to explicitly avoid (at least) print-statement which throws false-positives for folks not porting to Python 3.

Closes #722 by partially reverting #954
@lock lock bot locked as resolved and limited conversation to collaborators Jul 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

print statement is highlighted by pylint
3 participants