-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
convert promnesia to a namespace package #225
convert promnesia to a namespace package #225
Conversation
I expect some tests here to fail/the mypy commands in will probably just continue pushing changes here and you may squash this PR at the end The only major concern is imports like
like in the example config will no longer work, as I deleted the Theres no real way to add a deprecation warning/notice for that, as far as I know -- it'd be a breaking change |
ok -- even with the
|
Hmm, this is a new one for me
Seems to work fine locally:
Oh -- seems its related to generating the reports?
Thought it might be related to the stub |
Seems it was trying to treat misc like a file instead of a directory for some reason?
|
Yeah, I think it's not great -- it will break existing installs. We should probably keep it for now and add a deprecation warning -- it'll still allow having namespaced But good to switch tests and docs to not using it, I think we should keep just one test using
Yeah, I think this is related to this mypy namespace package weirdness -- usually can be solved with a |
Seems that if the change is reverted, and > diff --git a/src/promnesia/__init__.py b/src/promnesia/__init__.py
new file mode 100644
index 0000000..cec15eb
--- /dev/null
+++ b/src/promnesia/__init__.py
@@ -0,0 +1,3 @@
+from pathlib import Path
+from .common import PathIsh, Visit, Source, last, Loc, Results, DbVisit, Context, Res
+
diff --git a/src/promnesia/__init__.pyi b/src/promnesia/__init__.pyi
deleted file mode 100644
index d436815..0000000
--- a/src/promnesia/__init__.pyi
+++ /dev/null
@@ -1,2 +0,0 @@
-# NOTE: without __init__.py/__init__.pyi, mypy behaves weird.
-# https://github.com/karlicoss/pymplate/blob/master/src/karlicoss_pymplate/__init__.pyi
In order to use native namespace packages, like described in PEP420, you cant have an So -- I don't see a way to convert this to a namespace without it being a breaking change -- can add the deprecation warning for now and then maybe in a few months/years actually convert it. Hard to catch the warning as I'm not sure where its being triggered, but I modified the very basic test to use For now I can rename my package to install it as another module, and just import like |
Yeah indeed, looked it up, and it seems that parent package prevents access to child namespace. And we can think about something in the meantime... maybe some mad dynamic magic to patch up the config? |
Hmm -- I think the issue is still if If the purpose there is to allow overriding, its quite involved and I'd think thered only be 2 or 3 people using it before an eventual switch to namespace packages. Currently I get get around 'overriding' by just renaming my |
Ah no -- I meant
|
Ah, patching the imports in the config -- yeah, I dont see an immediate problem with that |
Was looking into patching imports in the config. At least in 3.9, after Doesn't seem as to do on 3.7 or 3.8 though, and would likely want to support that. Currently I just think its more trouble than its worth, my modules are fine as a separate package and I just import stuff into my config file, all works fine May look into traversing with |
initial attempt at converting this to a namespace package
this allows someone to install their own modules alongside
promnesia.sources
, and possibly overridesources
with their own changesFor reference: https://github.com/karlicoss/HPI/blob/master/doc/MODULE_DESIGN.org#namespace-packages
not being familiar with promnesia, was pretty painless to create a Source for my discord module
https://github.com/seanbreckenridge/promnesia
https://github.com/seanbreckenridge/HPI/blob/master/my/discord.py