Conversation
Contributor
|
Doesn't follow the contribution guidelines, closing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
src/semble/index/files.pymaps 347 file extensions to 265 languages. 61 of thoselanguages cover more than one extension, so their names are repeated 82 times
across the table. Since these are module-level string literals, every duplicate is
interned at import — this module is imported by the indexer, the cache layer and
the CLI, and
sembletypically runs as a long-lived MCP server.This splits the table in two:
_LANGUAGE_EXTENSIONS— the 61 languages reached by 2+ extensions, each namedonce next to its extensions.
_SINGLE_EXTENSION_LANGUAGE— the 204 extensions whose language is unique,unchanged and in the original row order.
_EXTENSION_TO_LANGUAGEis then built from the two. It is still adict[str, str]with the same 347 entries; only the source of the data changed.
Why group these at all: the grouped map is also the honest answer to "which
languages have several extensions?" — currently that is spread over 143 rows.
Verification
_EXTENSION_TO_LANGUAGEcompared entry-by-entry againstmain: 347/347 identical.ALL_LANGUAGES,_CODE_LANGUAGES,_DOC_LANGUAGES,_CONFIG_LANGUAGES,_DATA_LANGUAGES,_LANGUAGE_TO_EXTENSIONS,_CONTENT_TYPE_LANGUAGES: identical.detect_language()probed on 16 filenames;get_extensions()probed on 5content-type combinations: identical output.
tests/test_files.pycoversdetect_languageandget_extensionsand passes unmodified.Diff: one file, one module-level table. No tests, no other modules, no new deps.