Skip to content

Commit 41120bc

Browse files
author
colinmcneil
committed
Instruct no uuid module
1 parent e976613 commit 41120bc

File tree

6 files changed

+36
-18
lines changed

6 files changed

+36
-18
lines changed

prompts/pylint/2-make-db-schema.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,10 @@ tools:
3535
delete the /thread/db.sqlite
3636

3737
Write a SQL schema for a table named RANGES with columns ID, PATH, START_LINE, END_LINE, START_COLUMN, and
38-
END_COLUMN. The ID is the primary key and auto increments.
38+
END_COLUMN. The ID is going to be a unique string.
3939

40-
Write a SQL schema for a table named VIOLATIONS with a foreign key named RANGE of type ID, STRING, and columns
41-
MESSAGE, TYPE, VIOLATION_ID. The ID is the primary key, and auto increments.
42-
43-
allow END_LINE and END_COLUMN to be nullable.
40+
Write a SQL schema for a table named VIOLATIONS which references RANGES with fk `RANGE_ID`, and columns
41+
ID, MESSAGE, TYPE, and VIOLATION_ID. The ID is the primary key, and auto increments.
4442

4543
Run the sqlite command with the database set to `/thread/db.sqlite` and send the SQL generated above.
4644

prompts/pylint/3-generate-violation-insert.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,19 @@ It should then iterate over each element of an array with the following schema:
2222
```json
2323
[
2424
{"message": "some violation", "path": "app.py", "type": "error",
25-
"line": 0, "column": 0, "endLine": 1, "endColumn": 1, "path": "src/app.py"}
25+
"line": 0, "column": 0, "endLine": None, "endColumn": 1, "path": "src/app.py"}
2626
]
2727

2828
```
2929

3030
For each element of the array, it should create two INSERT statements.
31-
The first should insert the columns PATH, START_LINE, END_LINE, START_COLUMN, END_COLUMN
32-
into a tabled named RANGES using the properties from the map.
33-
The second should insert the columns MESSAGE, TYPE, RANGE, VIOLATION_ID into a table named VIOLATIONS
34-
using the properties from the map. The RANGE column should be the ID of the previous row in the RANGES table.
31+
32+
1. The first should insert the columns ID,PATH, START_LINE, END_LINE, START_COLUMN, END_COLUMN
33+
into a tabled named RANGES using the properties from the map. ID should be a random string. No uuid module here.
34+
2. The second should insert the columns MESSAGE, TYPE, RANGE_ID, VIOLATION_ID into a table named VIOLATIONS using the properties from the map. The RANGE_ID will be the same random string from before.
35+
36+
If the violation doesn't have an `endLine` or `endColumn` you should simply re-use the start position.
37+
3538
If any strings contain single quotes, they should be escaped.
3639

3740
Line and column represent START_LINE and START_COLUMN

prompts/pylint/4-run-violation-insert.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ docker run -it --rm -v thread:/thread \
4949
docker run -it --rm -v thread:/thread \
5050
vonwig/sqlite:latest \
5151
/thread/db.sqlite \
52-
"SELECT * FROM VIOLATIONS INNER JOIN RANGES ON VIOLATIONS.RANGE = RANGES.ID WHERE RANGES.PATH = 'src/app.py'"
52+
"SELECT * FROM VIOLATIONS INNER JOIN RANGES ON VIOLATIONS.RANGE_ID = RANGES.ID WHERE RANGES.PATH = 'src/app.py'"
5353
```
5454

5555
```

prompts/pylint/5-1-insert-top-level-ranges.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,16 @@ An example parsed file:
118118
```
119119
to get the ranges of each top level node into capturing groups.
120120
Write the ranges to `/thread/ranges.sql` in the form of sql
121-
`INSERT INTO RANGES (START_LINE, END_LINE, START_COLUMN, END_COLUMN, PATH) values (...)`
121+
`INSERT INTO RANGES (ID, START_LINE, END_LINE, START_COLUMN, END_COLUMN, PATH) values (...)`
122+
123+
You need to generate a random string without importing any modules.
122124

123125
Example output of script would be the creation of file `/thread/ranges.sql` with contents:
124126

125127
```sql
126-
INSERT INTO RANGES (START_LINE, START_COLUMN, END_LINE, END_COLUMN, PATH) values (0,0,0,21, 'main.py')
127-
INSERT INTO RANGES (START_LINE, START_COLUMN, END_LINE, END_COLUMN, PATH) values (2,0,2,37, 'main.py')
128-
INSERT INTO RANGES (START_LINE, START_COLUMN, END_LINE, END_COLUMN, PATH) values (4,0,5,17, 'main.py')
128+
INSERT INTO RANGES (ID, START_LINE, START_COLUMN, END_LINE, END_COLUMN, PATH) values ('<random-string>', 0,0,0,21, 'main.py')
129+
INSERT INTO RANGES (ID, START_LINE, START_COLUMN, END_LINE, END_COLUMN, PATH) values ('<random-string>', 2,0,2,37, 'main.py')
130+
INSERT INTO RANGES (ID, START_LINE, START_COLUMN, END_LINE, END_COLUMN, PATH) values ('<random-string>', 4,0,5,17, 'main.py')
129131
```
130132

131133
5. Execute the code in the javascript sandbox.

prompts/pylint/5-2-insert-code.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ where query selects everything from the RANGES table where END_LINE is not null.
6161
we get something like
6262
```csv
6363
ID,PATH,START_LINE,END_LINE,START_COLUMN,END_COLUMN
64-
125,wsgi_skylines.py,11,104,0,61
64+
1234-abcd-1234,wsgi_skylines.py,11,104,0,61
6565
```
6666

6767
So, write a JS script to
@@ -75,6 +75,6 @@ The CODE_AT_RANGE is the sliced content at PATH
7575
Example `/thread/code_insert/insert_code.sql` file:
7676

7777
```sql
78-
INSERT INTO CODE (RANGE_ID, CODE_AT_RANGE) (125, "<Contents of wsgi_skylines from line 11 to 104>")
78+
INSERT INTO CODE (RANGE_ID, CODE_AT_RANGE) ('1234-abcd-1234', "<Contents of wsgi_skylines from line 11 to 104>")
7979
```
8080

prompts/pylint/generic_query.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,19 @@ tools:
2020

2121
# prompt user
2222

23-
How many rows are in the ranges and violations tables? Use database `/thread/db.sqlite`
23+
The database is `/thread/db.sqlite`
24+
25+
Tables:
26+
CODE
27+
RANGES
28+
VIOLATIONS
29+
30+
Both violations and code tables share a foreign key reference to RANGES.
31+
32+
Query the shcema of all of these tables.
33+
34+
Answer the following questions:
35+
36+
What is the last violation with a non-null END_LINE in ranges?
37+
38+
What is the code for that violation?

0 commit comments

Comments
 (0)