• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

source-academy / py-slang / 28318944605
75%

Build:
DEFAULT BRANCH: main
Ran 28 Jun 2026 10:16AM UTC
Jobs 1
Files 76
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

28 Jun 2026 10:13AM UTC coverage: 75.202% (+0.2%) from 74.957%
28318944605

push

github

web-flow
feat: implement global keyword for Python §3 and §4 (#173)

* feat: implement global keyword for Python chapters 3 and 4

Adds full resolver and CSE interpreter support for the `global`
statement added to the Python §3/§4 spec in PR #162.

Resolver changes (resolver.ts):
- scanGlobalDeclarations() recursively finds `global x` declarations
  in a function body without descending into nested functions
- visitFunctionDefStmt pre-declares globally-named variables in the
  outermost environment so chain-walk lookups find them
- resolve() pre-pass skips locally hoisting names declared global
- visitForStmt skips declaring the loop target locally when global

CSE interpreter changes:
- closure.ts: adds globalVariables: Set<string> field
- utils.ts: adds getProgramEnvironment(), pyGetGlobalVariable(), and
  scanForGlobalDeclarations(); scanForAssignments() now accepts a
  globalNames exclusion set so global names stay out of localVariables
- interpreter.ts: Global node handler (no-op); FunctionDef computes
  globalVariables before building the closure; Variable reads from
  programEnvironment for global names; ASSIGNMENT writes to
  programEnvironment for global names

Validator:
- NoGlobalValidator blocks `global` in chapters 1 and 2

Tests (global-keyword.test.ts): 13 tests covering validator
rejection/acceptance, basic write, read-through, repeated mutation,
scope isolation between functions, nested-function bypass of enclosing
scope, global inside an if-branch, late creation of a global name, and
print output.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: recurse into single-node AST children in scanForGlobalDeclarations

The previous implementation only iterated over array-valued properties,
missing single-object children such as the elif node stored in
If.elseBlock. A global declaration inside an elif branch would silently
be treated as a local variable, causing a NameError at runtime.

Now also recurse into any non-array child that... (continued)

1765 of 2597 branches covered (67.96%)

Branch coverage included in aggregate %.

86 of 93 new or added lines in 7 files covered. (92.47%)

4849 of 6198 relevant lines covered (78.23%)

14253.85 hits per line

Uncovered Changes

Lines Coverage ∆ File
5
77.31
1.68% src/engines/cse/utils.ts
2
78.13
2.49% src/resolver/resolver.ts
Jobs
ID Job ID Ran Files Coverage
1 28318944605.1 28 Jun 2026 10:16AM UTC 76
75.2
GitHub Action Run
Source Files on build 28318944605
  • Tree
  • List 76
  • Changed 7
  • Source Changed 6
  • Coverage Changed 7
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • Github Actions Build #28318944605
  • ebdb4752 on github
  • Prev Build on main (#28318104243)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc