-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'python/main' into consolidate
- Loading branch information
Showing
32 changed files
with
3,131 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,111 @@ | ||
--- | ||
title: Test - add multiple bare imports | ||
--- | ||
|
||
```grit | ||
engine marzano(0.1) | ||
language python | ||
`$_` where { | ||
$import_math = "math", | ||
$import_math <: ensure_bare_import(), | ||
$import_re = "re", | ||
$import_re <: ensure_bare_import(), | ||
$import_json = "json", | ||
$import_json <: ensure_bare_import(), | ||
} | ||
``` | ||
|
||
## Add all imports if none is imported | ||
|
||
|
||
```python | ||
``` | ||
|
||
```python | ||
import math | ||
import re | ||
import json | ||
|
||
|
||
``` | ||
|
||
## Add missing imports | ||
|
||
```python | ||
import math | ||
import re | ||
``` | ||
|
||
```python | ||
import json | ||
|
||
import math | ||
import re | ||
``` | ||
|
||
## Add missing imports | ||
|
||
```python | ||
import json | ||
import re | ||
``` | ||
|
||
```python | ||
import math | ||
|
||
import json | ||
import re | ||
``` | ||
|
||
## Add missing import, all in one line | ||
|
||
```python | ||
import json, math | ||
``` | ||
|
||
```python | ||
import re | ||
|
||
import json, math | ||
``` | ||
|
||
|
||
## Don't add duplicate imports | ||
|
||
```python | ||
import math | ||
import json | ||
import re | ||
``` | ||
|
||
```python | ||
import math | ||
import json | ||
import re | ||
``` | ||
|
||
## Don't add duplicate imports (different order) | ||
|
||
```python | ||
import re | ||
import json | ||
import math | ||
``` | ||
|
||
```python | ||
import re | ||
import json | ||
import math | ||
``` | ||
|
||
## Don't add duplicate imports, all in one line | ||
|
||
```python | ||
import json, math, re | ||
``` | ||
|
||
```python | ||
import json, math, re | ||
``` |
This file contains 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,36 @@ | ||
--- | ||
title: Test - add one bare import | ||
--- | ||
|
||
```grit | ||
engine marzano(0.1) | ||
language python | ||
`$_` where { | ||
$import = "math", | ||
$import <: ensure_bare_import(), | ||
} | ||
``` | ||
|
||
## Add one bare import | ||
|
||
|
||
```python | ||
``` | ||
|
||
```python | ||
import math | ||
|
||
|
||
``` | ||
|
||
## Do not add duplicate bare import | ||
|
||
```python | ||
import math | ||
``` | ||
|
||
```python | ||
import math | ||
``` |
This file contains 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,58 @@ | ||
--- | ||
title: Test - ensure import from | ||
--- | ||
|
||
```grit | ||
engine marzano(0.1) | ||
language python | ||
`$_` where { | ||
$import = "prod", | ||
$import <: ensure_import_from(source = `math`), | ||
} | ||
``` | ||
|
||
## Add missing import | ||
|
||
|
||
```python | ||
``` | ||
|
||
```python | ||
from math import prod | ||
|
||
|
||
``` | ||
|
||
## Add one more name to source | ||
|
||
```python | ||
from math import log | ||
``` | ||
|
||
```python | ||
from math import log, prod | ||
``` | ||
|
||
## Keep existing import | ||
|
||
```python | ||
from math import prod | ||
``` | ||
|
||
```python | ||
from math import prod | ||
``` | ||
|
||
## Add from import even if there is a bare import | ||
|
||
```python | ||
import math | ||
``` | ||
|
||
```python | ||
from math import prod | ||
|
||
import math | ||
``` |
This file contains 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,93 @@ | ||
--- | ||
title: Test - is bare imported | ||
--- | ||
|
||
```grit | ||
engine marzano(0.1) | ||
language python | ||
integer() as $int where { | ||
$math = "math", | ||
$re = "re", | ||
$json = "json", | ||
if ($math <: is_bare_imported()) { | ||
$has_math = "true" | ||
} | ||
else { | ||
$has_math = "false" | ||
}, | ||
if ($re <: is_bare_imported()) { | ||
$has_re = "true" | ||
} | ||
else { | ||
$has_re = "false" | ||
}, | ||
if ($json <: is_bare_imported()) { | ||
$has_json = "true" | ||
} | ||
else { | ||
$has_json = "false" | ||
} | ||
} => `$has_math, $has_re, $has_json` | ||
``` | ||
|
||
|
||
## All bare imports missing | ||
|
||
```python | ||
42 | ||
``` | ||
|
||
```python | ||
false, false, false | ||
``` | ||
|
||
## Two bare imports present | ||
|
||
```python | ||
import math | ||
import json | ||
|
||
42 | ||
``` | ||
|
||
```python | ||
import math | ||
import json | ||
|
||
true, false, true | ||
``` | ||
|
||
## Imported bare import as part of a list | ||
|
||
```python | ||
import json, re | ||
|
||
42 | ||
``` | ||
|
||
```python | ||
import json, re | ||
|
||
false, true, true | ||
``` | ||
|
||
## From import is not a bare import | ||
|
||
```python | ||
from math import log | ||
from re import match | ||
|
||
import json | ||
|
||
42 | ||
``` | ||
|
||
```python | ||
from math import log | ||
from re import match | ||
|
||
import json | ||
|
||
false, false, true | ||
``` |
Oops, something went wrong.