Skip to content

Commit 944cc0e

Browse files
committed
fix: incorrect copy applied to NameError variant
1 parent 5eaf203 commit 944cc0e

3 files changed

Lines changed: 22 additions & 20 deletions

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,12 @@ In brief:
9191

9292
```bash
9393
npm install
94-
npm run build -- --watch
94+
npm run dev:build # watch and build everything
9595
npm test
9696
```
9797

98+
For a one-off full build use: `npm run build:all`
99+
98100
### Copydecks
99101

100102
Copydecks are JSON files that contain rules and templates for matching and explaining errors. They are stored in `copydecks/` and can be edited or added to.

copydecks/en/copydeck.json

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"version": 1
55
},
66

7-
"glossary": {
7+
"glossaryForTranslators": {
88
"about": "Tokens written as {{token_name}} are filled in automatically at render time with real values from the Python error. You may move them to suit your language's word order, but do not translate, rename, or remove them. No HTML is needed around them as styling is applied automatically. Keys starting with _ are metadata for translators - do not translate or modify them.",
99
"tokens": {
1010
"name": {
@@ -36,35 +36,35 @@
3636
"variants": [
3737
{
3838
"if": {
39-
"not_message": ["is not defined"]
39+
"match_message": ["cannot access free variable", "not associated with a value"]
4040
},
41-
"title": "This variable doesn't exist yet",
42-
"summary": "Your code uses the variable {{name}}, but it hasn't been created yet. Check {{loc}}. If you meant to print the text {{name}}, put it in double quotes.",
43-
"why": "Without speech marks Python treats {{name}} as a variable, and this variable does not exist yet.",
41+
"title": "Variable used before it gets a value here",
42+
"summary": "{{name}} is used at {{loc}} before it has been given a value in the function that surrounds it. It is set later, but not before it is used.",
43+
"why": "A variable from an enclosing function only becomes available once the line that assigns it has run. Using it earlier - for example from an inner function that runs first - leaves it without a value.",
4444
"steps": [
45-
"If it is meant to be text, put speech marks around {{name}}.",
46-
"If it is meant to be a variable, make it first (for example: {{name}} = 0).",
47-
"Check spelling and capital letters."
45+
"Give {{name}} a value before the line that uses it.",
46+
"If an inner function needs it, pass the value in as an argument instead of relying on the enclosing scope."
4847
],
4948
"_placeholders": {
50-
"name": "The undefined variable name, e.g. kittens",
51-
"loc": "Where it was used, e.g. line 2 in main.py"
49+
"name": "The enclosing-scope variable name, e.g. total",
50+
"loc": "Where it was used, e.g. line 3 in main.py"
5251
}
5352
},
5453
{
5554
"if": {
5655
"match_message": ["is not defined"]
5756
},
58-
"title": "This variable doesn't exist here",
59-
"summary": "{{name}} might be created somewhere else, but you're using it at {{loc}}. If you meant the text {{name}}, put it in double quotes.",
60-
"why": "A variable created in another place might not be available here.",
57+
"title": "This variable doesn't exist yet",
58+
"summary": "Your code uses the variable {{name}}, but this hasn't been created yet. Check {{loc}}. If you meant to print the text {{name}}, put it in double quotes.",
59+
"why": "Without speech marks Python treats {{name}} as a variable and this variable does not exist yet.",
6160
"steps": [
62-
"Move the line that makes it to above where you use it.",
63-
"Or set it here just before you use it."
61+
"If it is meant to be text put speech marks around {{name}}.",
62+
"If it is meant to be a variable make it first (for example: {{name}} = 0).",
63+
"Check spelling and capital letters."
6464
],
6565
"_placeholders": {
66-
"name": "The variable name used out of scope, e.g. total",
67-
"loc": "Where it was referenced, e.g. line 8 in main.py"
66+
"name": "The undefined variable name, e.g. kittens",
67+
"loc": "Where it was used, e.g. line 2 in main.py"
6868
}
6969
}
7070
]

docs/demo-examples.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export const examples = [
22
{
3-
title: "NameError - Variable Not Created Yet",
3+
title: "NameError - Variable Used Before Assignment (enclosing scope)",
44
runtime: "pyodide",
55
expectedVariantId: "NameError/variants/0",
66
code: `def outer():
@@ -18,7 +18,7 @@ outer()`,
1818
NameError: cannot access free variable 'total' where it is not associated with a value in enclosing scope`
1919
},
2020
{
21-
title: "NameError - Variable Not Defined Here",
21+
title: "NameError - Variable Not Defined",
2222
runtime: "pyodide",
2323
expectedVariantId: "NameError/variants/1",
2424
code: `print("Hello")

0 commit comments

Comments
 (0)