Skip to content

Tidy namespace#118

Merged
15 commits merged intomainfrom
tidy-namespace
Jun 24, 2025
Merged

Tidy namespace#118
15 commits merged intomainfrom
tidy-namespace

Conversation

@rwb27
Copy link
Copy Markdown
Collaborator

@rwb27 rwb27 commented Jun 24, 2025

This PR is replaced by #121

Currently, there are lots of imports from quite deep within this library that should be easier to find. @julianstirling suggested adding a useful set of top-level objects to the top level __init__ module, so that

from labthings_fastapi.thing import Thing
from labthings_fastapi.descriptors import ThingProperty, ThingSetting
from labthings_fastapi.decorators import thing_action

could become

from labthings_fastapi import Thing, ThingProperty, ThingSetting, thing_action

It might even become a helpful convention to import labthings as lt and then use lt.Thing etc.

This feels like it should be simple, and all the symbols above work just fine. However, I have run into problems in the past when I tried to do this (specifically for labthings_fastapi.dependencies) because of circular references. This might limit how many things can usefully be exposed at top level.

Also, at the moment there is one labthings_fastapi module that is both client and server. If labthings_fastapi is installed without the server extra, i.e. it's being used only as a client over HTTP, adding these top level imports will break it - because labthings_fastapi.thing has a hard dependency on fastapi, for example. I suspect the resolution to that is to split the package into a client and server module - but I'd welcome opinions on what makes most sense.

Depends on #110

N.B. this is currently based on @julianstirling's branch for #110 to avoid merge conflicts. It should not be merged before #110.

@barecheck
Copy link
Copy Markdown

barecheck bot commented Jun 24, 2025

@rwb27 rwb27 marked this pull request as draft June 24, 2025 20:51
@julianstirling julianstirling closed this pull request by merging all changes into main in c2e09b8 Jun 24, 2025
@julianstirling julianstirling deleted the tidy-namespace branch June 24, 2025 21:18
@rwb27
Copy link
Copy Markdown
Collaborator Author

rwb27 commented Jun 26, 2025

This PR was marked as merged before any commits were added. It makes no changes to the code.

The branch tidy-namespace was based off the branch for #110 and was marked as merged when #110 was merged.

I will re-open a new PR for this #121.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants