Skip to content

Commit df9d509

Browse files
committed
fix root py file detection in python policy
1 parent 1e4e679 commit df9d509

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

plugins/python3/src/policy.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,15 @@ impl StudentFilePolicy for Python3StudentFilePolicy {
2828
|| path
2929
.components()
3030
.any(|c| c.as_os_str() == OsStr::new("__pycache__"));
31+
3132
// .py files in exercise root are student source files
32-
let is_py_in_root = path.extension() == Some(OsStr::new("py")) && path.parent().is_none();
33+
let is_in_project_root = match path.parent() {
34+
Some(s) => s.as_os_str().is_empty(),
35+
None => true,
36+
};
37+
let is_py_file = path.extension() == Some(OsStr::new("py"));
3338

34-
in_src && !is_cache_file || is_py_in_root
39+
in_src && !is_cache_file || is_in_project_root && is_py_file
3540
}
3641
}
3742

0 commit comments

Comments
 (0)