Coding 2022-03-07
Oh boy, it has been a long time since I went over some of this stuff. This is for MOTR, and I'm starting with the flake8 wrapper. Going from the top, we have:
- Program subclass
- flake8 Label
- Command and Option aliases
- The necessary Command instance
- Option instance, which should just need to be wrapped in an invocation.Static
- "builder" functions, which need a little more work
Both of the definitions share a Label, which needs to get reworked into a ValueAdaptor. Let's see if I can sketch that out.
@adaptor(PACKAGE_LABEL)
def package(python_package: PythonPackage) -> PathStr:
return python_package.root
That is... probably going to come in useful for other modules.
Anyway, to use it here, I'm going to need something like...
@adaptive_dynamic(package)
def srcdir(objects: Objects, items: Items) -> Requirements[Option]:
yield from ()
package = items[PACKAGE_LABEL]
if not package.src:
raise NotImplementedError
return basic_option(objects[ROOT_LABEL] / package.root / "src")
@adaptive_dynamic(package)
def testdir(objects: Objects, items: Items) -> Requirements[Option]:
yield from ()
return basic_option(
objects[ROOT_LABEL] / items[PACKAGE_LABEL].root / "tests"
)
This works out to no code changes within the functions, I just need to change the decorator on them, and for that, I first need to write the new decorator.
Let me see if I can bang that out quickly.
...
All right, I'm not really sure about "quickly", but it's out.
And I'm tired.
I'm going to get to bed to try to avoid feeling even lousier. Hopefully, this entry should provide a solid groundwork for when I get back to this.
Good night.