Skip to content

Commit 05f031f

Browse files
authored
Merge branch 'main' into patch-1
2 parents 57a5c0e + 25ba3a3 commit 05f031f

10 files changed

Lines changed: 58 additions & 182 deletions

File tree

.github/workflows/downstream.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@ name: Run Downstream tests
22

33
on:
44
push:
5+
paths-ignore:
6+
- 'docs/**'
7+
- '**.md'
8+
- '**.rst'
59
pull_request:
10+
paths-ignore:
11+
- 'docs/**'
12+
- '**.md'
13+
- '**.rst'
614
# Run weekly on Monday at 1:23 UTC
715
schedule:
816
- cron: '23 1 * * 1'
@@ -25,7 +33,7 @@ jobs:
2533
os: [ubuntu-latest]
2634
python-version: ["3.13"]
2735
include:
28-
- os: macos-13
36+
- os: macos-14
2937
python-version: "3.13"
3038

3139
steps:

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ jobs:
105105
- name: Upload coverage to Codecov
106106
uses: codecov/codecov-action@v5
107107
with:
108+
token: ${{ secrets.CODECOV_TOKEN }}
108109
name: Test
109110
files: /home/runner/work/ipython/ipython/coverage.xml
110111

IPython/core/async_helpers.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,20 +136,15 @@ def _pseudo_sync_runner(coro):
136136

137137

138138
def _should_be_async(cell: str) -> bool:
139-
"""Detect if a block of code need to be wrapped in an `async def`
139+
"""Detect if a block of code needs to be wrapped in an `async def`
140140
141-
Attempt to parse the block of code, it it compile we're fine.
142-
Otherwise we wrap if and try to compile.
143-
144-
If it works, assume it should be async. Otherwise Return False.
145-
146-
Not handled yet: If the block of code has a return statement as the top
147-
level, it will be seen as async. This is a know limitation.
141+
If the code block has a top-level return statement or is otherwise
142+
invalid, `False` will be returned.
148143
"""
149144
try:
150145
code = compile(
151146
cell, "<>", "exec", flags=getattr(ast, "PyCF_ALLOW_TOP_LEVEL_AWAIT", 0x0)
152147
)
153148
return inspect.CO_COROUTINE & code.co_flags == inspect.CO_COROUTINE
154-
except (SyntaxError, MemoryError):
149+
except (SyntaxError, ValueError, MemoryError):
155150
return False

IPython/core/interactiveshell.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2141,7 +2141,7 @@ def get_exception_only(self, exc_tuple=None):
21412141

21422142
def showtraceback(
21432143
self,
2144-
exc_tuple: tuple[type[BaseException], BaseException, Any] | None = None,
2144+
exc_tuple: tuple[type[BaseException], BaseException, AnyType] | None = None,
21452145
filename: str | None = None,
21462146
tb_offset: int | None = None,
21472147
exception_only: bool = False,

codecov.yml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,37 @@ coverage:
55
default: false
66
library:
77
target: auto
8-
paths: ['!.*/tests/.*']
8+
paths:
9+
- '!**/tests/**'
10+
- '!**/testing/**'
911
threshold: 0.1%
1012
tests:
1113
target: auto
12-
paths: ['.*/tests/.*']
14+
paths:
15+
- '**/tests/**'
16+
- '**/testing/**'
1317
threshold: 0.1%
18+
flag_management:
19+
default_rules:
20+
statuses:
21+
- type: patch
22+
target: auto%
23+
threshold: 0.1%
24+
- type: project
25+
target: auto%
26+
threshold: 0.1%
27+
individual_flags:
28+
- name: unit-tests
29+
paths:
30+
- '**/tests/**'
31+
- '**/testing/**'
32+
- name: library
33+
paths:
34+
- '!**/tests/**'
35+
- '!**/testing/**'
1436
codecov:
1537
require_ci_to_pass: false
38+
branch: main
1639

1740
ignore:
1841
- IPython/kernel/*

docs/source/conf.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@
9292
}
9393
)
9494

95+
# External links configuration (replaces custom github extension)
96+
extlinks = {
97+
"ghissue": ("https://github.com/ipython/ipython/issues/%s/", "#%s"),
98+
"ghpull": ("https://github.com/ipython/ipython/pull/%s/", "PR #%s"),
99+
}
100+
95101

96102
# Options for HTML output
97103
# -----------------------

docs/source/sphinx.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ extensions = [
1313
"sphinx.ext.inheritance_diagram",
1414
"sphinx.ext.intersphinx",
1515
"sphinx.ext.graphviz",
16+
"sphinx.ext.extlinks", # for easy GitHub links
1617
"sphinxcontrib.jquery",
1718
"IPython.sphinxext.ipython_console_highlighting",
1819
"IPython.sphinxext.ipython_directive",
1920
"sphinx.ext.napoleon", # to preprocess docstrings
20-
"github", # for easy GitHub links
2121
"magics",
2222
"configtraits",
2323
]

docs/sphinxext/github.py

Lines changed: 0 additions & 168 deletions
This file was deleted.

tests/test_async_helpers.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
Should only trigger on python 3.5+ or will have syntax errors.
55
"""
66

7+
import sys
78
from itertools import chain, repeat
89
from textwrap import dedent, indent
910
from typing import TYPE_CHECKING
@@ -44,6 +45,16 @@ async def awaitable():
4445
)
4546
)
4647

48+
self.assertFalse(_should_be_async("return await foo()"))
49+
self.assertFalse(_should_be_async("return bar()"))
50+
self.assertFalse(_should_be_async("some invalid Python code"))
51+
52+
self.assertFalse(_should_be_async("'\\ud800'"))
53+
54+
if sys.version_info >= (3, 13):
55+
# Note: the next assert assumes the tests run without the `-OO` flag
56+
self.assertFalse(_should_be_async("'\\ud800'\nawait foo"))
57+
4758
def _get_top_level_cases(self):
4859
# These are test cases that should be valid in a function
4960
# but invalid outside of a function.
File renamed without changes.

0 commit comments

Comments
 (0)