8000 fix: Allow empty project name and version (#107) · efritz/scip-python@6c40b9f · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit 6c40b9f

Browse files
fix: Allow empty project name and version (sourcegraph#107)
1 parent cd63124 commit 6c40b9f

File tree

6 files changed

+31
-18
lines changed

6 files changed

+31
-18
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
def main():
2+
pass
3+
4+
main()
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# < definition scip-python python . . main/__init__:
2+
#documentation (module) main
3+
4+
def main():
5+
# ^^^^ definition . . main/main().
6+
# documentation ```python
7+
# > def main(): # -> None:
8+
# > ```
9+
pass
10+
11+
main()
12+
#^^^ reference . . main/main().
13+

packages/pyright-scip/snapshots/packageInfo.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
"odd_pkg_name_1": {
88
"name": "package with space",
99
"version": "0.1"
10+
},
11+
"empty_project_name_version": {
12+
"name": "",
13+
"version": ""
1014
}
1115
}
1216
}

packages/pyright-scip/src/MainCommand.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,15 @@ export function mainCommand(
5353

5454
command
5555
.command('index')
56-
.requiredOption('--project-name <name>', 'the name of the current project, pypi name if applicable')
57-
.option('--project-version <version>', 'the version of the current project, defaults to git revision')
56+
.option(
57+
'--project-name <name>',
58+
'The name of the current project, pypi name if applicable. The default empty project name only supports repository-local code navigation in Sourcegraph.',
59+
''
60+
)
61+
.option(
62+
'--project-version <version>',
63+
'The version of the current project. If not provided, defaults to the current git revision (if found).'
64+
)
5865
.option('--project-namespace <namespace>', 'A prefix to prepend to all module definitions in the current index')
5966
.option('--cwd <path>', 'working directory for executing scip-python', process.cwd())
6067
.option('--target-only <path>', 'limit analysis to the following path')

packages/pyright-scip/src/main-impl.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ function indexAction(options: IndexOptions): void {
2626

2727
// TODO: use setup.py / poetry to determine better projectName
2828
const projectName = options.projectName;
29-
if (!projectName || projectName == '') {
30-
console.warn('Must pass `--project-name`');
31-
return;
32-
}
3329

3430
// TODO: Use setup.py / poetry to determine better projectVersion
3531
// for now, the current hash works OK
@@ -39,8 +35,7 @@ function indexAction(options: IndexOptions): void {
3935
try {
4036
projectVersion = child_process.execSync('git rev-parse HEAD').toString().trim();
4137
} catch (e) {
42-
console.warn('Must either pass `--project-version` or run from within a git repository');
43-
return;
38+
projectVersion = '';
4439
}
4540
}
4641

packages/pyright-scip/src/treeVisitor.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -184,16 +184,6 @@ export class TreeVisitor extends ParseTreeWalker {
184184

185185
log.info('=> Working file:', config.sourceFile.getFilePath(), '<==');
186186

187-
// TODO: This should happen earlier, a bit weird to throw an error this deep
188-
// in the traversal
189-
if (!this.config.scipConfig.projectName) {
190-
throw 'Must have project name';
191-
}
192-
193-
if (!this.config.scipConfig.projectVersion) {
194-
throw 'Must have project version';
195-
}
196-
197187
this.evaluator = config.evaluator;
198188
this.program = config.program;
199189
this.document = config.document;

0 commit comments

Comments
 (0)
0