forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix linter installation #557
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
Merged
DonJayamanne
merged 48 commits into
microsoft:master
from
DonJayamanne:fixLinterInstallation
Jan 9, 2018
Merged
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
ecc1ca9
Fix Microsoft/vscode#37627 (#1368)
octref 7c5778c
Version 0.7.0 of extension (#1381)
DonJayamanne 9d1bf82
Update README.md
DonJayamanne ffba179
Update README.md
DonJayamanne 905c713
sync fork with upstream
DonJayamanne acc2109
fix readme
DonJayamanne d470523
Merge branch 'master' of https://github.com/Microsoft/vscode-python
DonJayamanne d392e8b
merged upstream
DonJayamanne 92f775f
Merge remote-tracking branch 'upstream/master'
DonJayamanne 32a6e53
Merge remote-tracking branch 'upstream/master'
DonJayamanne 4b30f2c
Merge remote-tracking branch 'upstream/master'
DonJayamanne e396752
Merge remote-tracking branch 'upstream/master'
DonJayamanne eff4792
Merge remote-tracking branch 'upstream/master'
DonJayamanne 4553c28
Merge remote-tracking branch 'upstream/master'
DonJayamanne 3c6520a
Merge remote-tracking branch 'upstream/master'
DonJayamanne 966e516
Merge remote-tracking branch 'upstream/master'
DonJayamanne 63d2d65
Merge remote-tracking branch 'upstream/master'
DonJayamanne f6d469e
Merge remote-tracking branch 'upstream/master'
DonJayamanne 029e055
Merge remote-tracking branch 'upstream/master'
DonJayamanne e8c71c0
Merge remote-tracking branch 'upstream/master'
DonJayamanne 51cf9d2
Merge remote-tracking branch 'upstream/master'
DonJayamanne 7aadc43
Merge remote-tracking branch 'upstream/master'
DonJayamanne f0f5c59
Merge remote-tracking branch 'upstream/master'
DonJayamanne b2b9da9
Merge remote-tracking branch 'upstream/master'
DonJayamanne 30a4091
Merge remote-tracking branch 'upstream/master'
DonJayamanne b16d2f9
Merge remote-tracking branch 'upstream/master'
DonJayamanne c8db345
Merge remote-tracking branch 'upstream/master'
DonJayamanne 0df7f16
Merge remote-tracking branch 'upstream/master'
DonJayamanne 3ccc881
Merge remote-tracking branch 'upstream/master'
DonJayamanne bb0709e
Merge remote-tracking branch 'upstream/master'
DonJayamanne 2c19004
Merge remote-tracking branch 'upstream/master'
DonJayamanne 8f224ab
Merge remote-tracking branch 'upstream/master'
DonJayamanne 41b7080
Merge remote-tracking branch 'upstream/master'
DonJayamanne dab38dc
Merge remote-tracking branch 'upstream/master'
DonJayamanne ae22dd4
Merge remote-tracking branch 'upstream/master'
DonJayamanne d2340d2
Merge remote-tracking branch 'upstream/master'
DonJayamanne 52bb7ae
Merge remote-tracking branch 'upstream/master'
DonJayamanne b6b2531
Merge remote-tracking branch 'upstream/master'
DonJayamanne 8d8d2fc
Merge remote-tracking branch 'upstream/master'
DonJayamanne c425a55
Merge remote-tracking branch 'upstream/master'
DonJayamanne 3963217
Merge remote-tracking branch 'upstream/master'
DonJayamanne a696f2a
Merge remote-tracking branch 'upstream/master'
DonJayamanne a31e659
Merge remote-tracking branch 'upstream/master'
DonJayamanne 2663cd5
Merge remote-tracking branch 'upstream/master'
DonJayamanne 7c85e0b
Merge remote-tracking branch 'upstream/master'
DonJayamanne beb82c2
Merge remote-tracking branch 'upstream/master'
DonJayamanne cae386f
clean up
DonJayamanne 6fa0f73
remove duplicate registration
DonJayamanne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| import * as assert from 'assert'; | ||
| import * as path from 'path'; | ||
| import { IFormattingSettings, PythonSettings } from '../../client/common/configSettings'; | ||
| import { EnumEx } from '../../client/common/enumUtils'; | ||
| import { Product } from '../../client/common/types'; | ||
| import { FormatterHelper } from '../../client/formatters/helper'; | ||
| import { FormatterId } from '../../client/formatters/types'; | ||
| import { initialize } from '../initialize'; | ||
|
|
||
| // tslint:disable-next-line:max-func-body-length | ||
| suite('Formatting - Helper', () => { | ||
| const formatHelper = new FormatterHelper(); | ||
| suiteSetup(initialize); | ||
|
|
||
| test('Ensure product is set in Execution Info', async () => { | ||
| [Product.autopep8, Product.yapf].forEach(formatter => { | ||
| const info = formatHelper.getExecutionInfo(formatter, []); | ||
| assert.equal(info.product, formatter, `Incorrect products for ${formatHelper.translateToId(formatter)}`); | ||
| }); | ||
| }); | ||
|
|
||
| test('Ensure executable is set in Execution Info', async () => { | ||
| const settings = PythonSettings.getInstance(); | ||
|
|
||
| [Product.autopep8, Product.yapf].forEach(formatter => { | ||
| const info = formatHelper.getExecutionInfo(formatter, []); | ||
| const names = formatHelper.getSettingsPropertyNames(formatter); | ||
| const execPath = settings.formatting[names.pathName] as string; | ||
| let moduleName: string | undefined; | ||
| if (path.basename(execPath) === execPath) { | ||
| moduleName = execPath; | ||
| } | ||
|
|
||
| assert.equal(info.execPath, execPath, `Incorrect executable paths for product ${formatHelper.translateToId(formatter)}`); | ||
| }); | ||
| }); | ||
|
|
||
| test('Ensure arguments are set in Execution Info', async () => { | ||
| const settings = PythonSettings.getInstance(); | ||
| const customArgs = ['1', '2', '3']; | ||
|
|
||
| [Product.autopep8, Product.yapf].forEach(formatter => { | ||
| const info = formatHelper.getExecutionInfo(formatter, []); | ||
| const names = formatHelper.getSettingsPropertyNames(formatter); | ||
| const args: string[] = Array.isArray(settings.formatting[names.argsName]) ? settings.formatting[names.argsName] as string[] : []; | ||
| const expectedArgs = args.concat(customArgs).join(','); | ||
|
|
||
| assert.equal(expectedArgs.endsWith(customArgs.join(',')), true, `Incorrect custom arguments for product ${formatHelper.translateToId(formatter)}`); | ||
|
|
||
| }); | ||
| }); | ||
|
|
||
| test('Ensure correct setting names are returned', async () => { | ||
| [Product.autopep8, Product.yapf].forEach(formatter => { | ||
| const translatedId = formatHelper.translateToId(formatter)!; | ||
| const settings = { | ||
| argsName: `${translatedId}Args` as keyof IFormattingSettings, | ||
| pathName: `${translatedId}Path` as keyof IFormattingSettings | ||
| }; | ||
|
|
||
| assert.deepEqual(formatHelper.getSettingsPropertyNames(formatter), settings, `Incorrect settings for product ${formatHelper.translateToId(formatter)}`); | ||
| }); | ||
| }); | ||
|
|
||
| test('Ensure translation of ids works', async () => { | ||
| const formatterMapping = new Map<Product, FormatterId>(); | ||
| formatterMapping.set(Product.autopep8, 'autopep8'); | ||
| formatterMapping.set(Product.yapf, 'yapf'); | ||
|
|
||
| [Product.autopep8, Product.yapf].forEach(formatter => { | ||
| const translatedId = formatHelper.translateToId(formatter); | ||
| assert.equal(translatedId, formatterMapping.get(formatter)!, `Incorrect translation for product ${formatHelper.translateToId(formatter)}`); | ||
| }); | ||
| }); | ||
|
|
||
| EnumEx.getValues<Product>(Product).forEach(product => { | ||
| const formatterMapping = new Map<Product, FormatterId>(); | ||
| formatterMapping.set(Product.autopep8, 'autopep8'); | ||
| formatterMapping.set(Product.yapf, 'yapf'); | ||
| if (formatterMapping.has(product)) { | ||
| return; | ||
| } | ||
|
|
||
| test(`Ensure translation of ids throws exceptions for unknown formatters (${product})`, async () => { | ||
| assert.throws(() => formatHelper.translateToId(product)); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| import * as assert from 'assert'; | ||
| import * as path from 'path'; | ||
| import { ILintingSettings, PythonSettings } from '../../client/common/configSettings'; | ||
| import { EnumEx } from '../../client/common/enumUtils'; | ||
| import { Product } from '../../client/common/types'; | ||
| import { LinterHelper } from '../../client/linters/helper'; | ||
| import { LinterId } from '../../client/linters/types'; | ||
| import { initialize } from '../initialize'; | ||
|
|
||
| // tslint:disable-next-line:max-func-body-length | ||
| suite('Linting - Helper', () => { | ||
| const linterHelper = new LinterHelper(); | ||
| suiteSetup(initialize); | ||
|
|
||
| test('Ensure product is set in Execution Info', async () => { | ||
| [Product.flake8, Product.mypy, Product.pep8, | ||
| Product.pydocstyle, Product.pylama, Product.pylint].forEach(linter => { | ||
| const info = linterHelper.getExecutionInfo(linter, []); | ||
| assert.equal(info.product, linter, `Incorrect products for ${linterHelper.translateToId(linter)}`); | ||
| }); | ||
| }); | ||
|
|
||
| test('Ensure executable is set in Execution Info', async () => { | ||
| const settings = PythonSettings.getInstance(); | ||
|
|
||
| [Product.flake8, Product.mypy, Product.pep8, | ||
| Product.pydocstyle, Product.pylama, Product.pylint].forEach(linter => { | ||
| const info = linterHelper.getExecutionInfo(linter, []); | ||
| const names = linterHelper.getSettingsPropertyNames(linter); | ||
| const execPath = settings.linting[names.pathName] as string; | ||
| let moduleName: string | undefined; | ||
| if (path.basename(execPath) === execPath && linter !== Product.prospector) { | ||
| moduleName = execPath; | ||
| } | ||
|
|
||
| assert.equal(info.execPath, execPath, `Incorrect executable paths for product ${linterHelper.translateToId(linter)}`); | ||
| }); | ||
| }); | ||
|
|
||
| test('Ensure arguments are set in Execution Info', async () => { | ||
| const settings = PythonSettings.getInstance(); | ||
| const customArgs = ['1', '2', '3']; | ||
|
|
||
| [Product.flake8, Product.mypy, Product.pep8, | ||
| Product.pydocstyle, Product.pylama, Product.pylint].forEach(linter => { | ||
| const info = linterHelper.getExecutionInfo(linter, []); | ||
| const names = linterHelper.getSettingsPropertyNames(linter); | ||
| const args: string[] = Array.isArray(settings.linting[names.argsName]) ? settings.linting[names.argsName] as string[] : []; | ||
| const expectedArgs = args.concat(customArgs).join(','); | ||
|
|
||
| assert.equal(expectedArgs.endsWith(customArgs.join(',')), true, `Incorrect custom arguments for product ${linterHelper.translateToId(linter)}`); | ||
|
|
||
| }); | ||
| }); | ||
|
|
||
| test('Ensure correct setting names are returned', async () => { | ||
| [Product.flake8, Product.mypy, Product.pep8, | ||
| Product.pydocstyle, Product.pylama, Product.pylint].forEach(linter => { | ||
| const translatedId = linterHelper.translateToId(linter)!; | ||
| const settings = { | ||
| argsName: `${translatedId}Args` as keyof ILintingSettings, | ||
| pathName: `${translatedId}Path` as keyof ILintingSettings, | ||
| enabledName: `${translatedId}Enabled` as keyof ILintingSettings | ||
| }; | ||
|
|
||
| assert.deepEqual(linterHelper.getSettingsPropertyNames(linter), settings, `Incorrect settings for product ${linterHelper.translateToId(linter)}`); | ||
| }); | ||
| }); | ||
|
|
||
| test('Ensure translation of ids works', async () => { | ||
| const linterIdMapping = new Map<Product, LinterId>(); | ||
| linterIdMapping.set(Product.flake8, 'flake8'); | ||
| linterIdMapping.set(Product.mypy, 'mypy'); | ||
| linterIdMapping.set(Product.pep8, 'pep8'); | ||
| linterIdMapping.set(Product.prospector, 'prospector'); | ||
| linterIdMapping.set(Product.pydocstyle, 'pydocstyle'); | ||
| linterIdMapping.set(Product.pylama, 'pylama'); | ||
| linterIdMapping.set(Product.pylint, 'pylint'); | ||
|
|
||
| [Product.flake8, Product.mypy, Product.pep8, | ||
| Product.pydocstyle, Product.pylama, Product.pylint].forEach(linter => { | ||
| const translatedId = linterHelper.translateToId(linter); | ||
| assert.equal(translatedId, linterIdMapping.get(linter)!, `Incorrect translation for product ${linterHelper.translateToId(linter)}`); | ||
| }); | ||
| }); | ||
|
|
||
| EnumEx.getValues<Product>(Product).forEach(product => { | ||
| const linterIdMapping = new Map<Product, LinterId>(); | ||
| linterIdMapping.set(Product.flake8, 'flake8'); | ||
| linterIdMapping.set(Product.mypy, 'mypy'); | ||
| linterIdMapping.set(Product.pep8, 'pep8'); | ||
| linterIdMapping.set(Product.prospector, 'prospector'); | ||
| linterIdMapping.set(Product.pydocstyle, 'pydocstyle'); | ||
| linterIdMapping.set(Product.pylama, 'pylama'); | ||
| linterIdMapping.set(Product.pylint, 'pylint'); | ||
| if (linterIdMapping.has(product)) { | ||
| return; | ||
| } | ||
|
|
||
| test(`Ensure translation of ids throws exceptions for unknown linters (${product})`, async () => { | ||
| assert.throws(() => linterHelper.translateToId(product)); | ||
| }); | ||
| }); | ||
| }); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fs.ArePathsSame?