check50 icon indicating copy to clipboard operation
check50 copied to clipboard

check50.import_checks should rename checks

Open Jelleas opened this issue 6 years ago • 1 comments

Something like:

check50.import_checks("../less", prefix="less_")

Right now it's too easy to break checks through naming conflicts.

This feature would require renaming in check50.runner._check_names.

There's also currently a weird dependency on the original function name, rather than the decorated one, within the dependency graph. This is caused because the CheckResults are created from the original function, and the dependency graph operates on these results. Down the line, this causes things to break if you rename the decorated function, but not the original one. We should change this such that everything uses the decorated function name as you would expect.

Here's a working example implemented in the checks:

https://github.com/minprog/cs50x/blob/2019/sentimental/init.py

Jelleas avatar Sep 29 '19 13:09 Jelleas

Yeah, import_checks is a bit of a misnomer. Really it just gets you a module from a file path, after which you have to do from x import * or it doesn't work anyway.

What does this do for checks in the current module which depend on checks in the imported module? e.g. resize/more has something like

import check50
less = check50.import_checks("../less")
from less import *
# exists defined in less
@check50.check(exists)
def ...

I agree we need some kind of namespacing tho.

cmlsharp avatar Apr 11 '20 16:04 cmlsharp