Skip to content
rlsbl.module_paths
On this page

The one module-prefix containment rule: a path is inside a prefix only at a separator boundary, so a neighbour with the same leading letters never matches.

#rlsbl.module_paths

#rlsbl.module_paths

The one module-prefix containment rule.

"Is import path X inside module Y?" is asked by the Go import scanner, the dead-module/dead-package detectors, the strictcli entry-point detector and the rlsbl rewrite go-module-path sweep. Every one of them used to spell the answer inline, and one of the spellings was wrong.

The rule, stated once ---------------------

A path is inside a module prefix when it IS the prefix, or when it continues past the prefix at a separator boundary. The separator is the ecosystem's own: / for Go import paths, . for Python and JVM dotted names.

The boundary is the whole rule. A bare path.startswith(prefix) also matches a DIFFERENT module whose name merely begins with the same letters -- github.com/o/foo matched github.com/o/foobar, and strictcli matched strictcli-extras -- which is a wrong answer, not a conservative one: it makes an unrelated third-party module look like the one being asked about.

There is deliberately no default separator. A caller that does not say which ecosystem's paths it is comparing has not decided, and a wrong default silently turns dotted names into never-matching ones (or the reverse).

#under_module_prefix

python
def under_module_prefix(path: str, prefix: str, *, sep: str) -> bool

True when path is prefix itself or lies beneath it.

Args:

  • path: the candidate import path (github.com/o/foo/bar, a.b.c).
  • prefix: the module path to test containment against.
  • sep: the ecosystem's path separator -- :data:GO_SEP or

:data:DOT_SEP. Required: see the module docstring.

An empty prefix matches nothing. Containment is asked of the pair as given; neither side is normalized, because a module path's case and punctuation are significant in both ecosystems this serves.

#go_import_under_module

python
def go_import_under_module(import_path: str, module_path: str) -> bool

True when a Go import_path belongs to the module at module_path.

#dotted_under_module

python
def dotted_under_module(name: str, prefix: str) -> bool

True when a dotted name (Python, Java, Kotlin) is inside prefix.

#rewrite_module_prefix

python
def rewrite_module_prefix(path: str, old_prefix: str, new_prefix: str, *, sep: str) -> str

Re-root path from old_prefix onto new_prefix.

Returns path unchanged when it is not under old_prefix, so a caller can map a whole import list through this without pre-filtering.

More tools from this site

  • claudestream Drive Claude Code from Python: run it as a subprocess and read its output as typed events, with async and sync sessions, sandbox policies, and tools you define in Python
  • claudewheel A TUI Claude Code Launcher that lets you have more than one profile, manage sessions lifecycle, pick the exact CC version, model to use (even older unlisted ones), pick which GitHub account to use, etc.
  • dirstat Fast, single-binary directory statistics CLI: every file under a tree grouped by format, with counts, sizes, and lines of code, as a colored terminal table or as JSON
  • fastware A batteries-included ASGI framework: msgspec JSON, a managed Granian server, dependency injection, SSE, WebSockets, auth, and a test client
  • go-toml-edit Zero-dep TOML editing library for Go with comment preservation
  • howmuchleft The fastest Claude Code statusline: context window, 5-hour, and weekly limit usage as three customizable gradient bars, rendering in about 6 ms
  • orxtra
  • pgdesign
  • predraw Declarative rendering pipeline: describe a scene in JSON and get SVG, PNG and WebP out, with light and dark style tokens, reusable components and text converted to path outlines
  • reposummary Turn a git repository's history into a Markdown journal: pick a time window or revision range and get a readable digest of what changed, optionally narrated by an LLM
  • safegit git wrapper CLI that gives each commit its own temporary index and retries ref updates on conflict, so concurrent agents share one repository
  • saferm Command-line replacement for rm that archives every deletion with a mandatory reason and the context it ran in, so deleted files can be listed, inspected and restored
  • selfdoc Static Site Generator that builds a project's documentation site directly from its source code, so the docs can never drift from the code they describe, with SEO/AEO, first-class blog, search, and cross-project linking built in
  • strictcli
  • stricttest An always-on test-isolation floor: a pytest plugin and a Go env-hygiene module that make a test suite structurally unable to reach real credentials, the real HOME, the network, or the development repository.
  • wesktop A Python framework that turns an ASGI web app into a desktop application, serving it from a local Granian server and displaying it in a native OS window via pywebview
Search