Skip to content

Commit 3a98cb3

Browse files
yangdanny97meta-codesync[bot]
authored andcommitted
allow await outside async function def for notebooks
Reviewed By: ndmitchell Differential Revision: D85445448 fbshipit-source-id: b44b2de1c1e7c8b7ab4a45c25de8ecff106c0475
1 parent accfb00 commit 3a98cb3

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

crates/pyrefly_python/src/module_path.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ impl ModulePath {
225225
self.style() == ModuleStyle::Interface
226226
}
227227

228+
pub fn is_notebook(&self) -> bool {
229+
self.as_path().extension() == Some("ipynb".as_ref())
230+
}
231+
228232
/// Attempt to match the given [`ModuleName`]'s components to this `ModulePath`,
229233
/// returning the directory that is the import root for the `ModuleName`, if
230234
/// *all* module components could be matched to directories. `ModulePath`s

pyrefly/lib/binding/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ impl<'a> BindingsBuilder<'a> {
723723
}
724724
Expr::Await(x) => {
725725
self.ensure_expr(&mut x.value, usage);
726-
if !self.scopes.is_in_async_def() {
726+
if !self.scopes.is_in_async_def() && !self.module_info.path().is_notebook() {
727727
self.error(
728728
x.range(),
729729
ErrorInfo::Kind(ErrorKind::InvalidSyntax),

0 commit comments

Comments
 (0)