Repository navigation
Fix medium-priority review issues in updates, versions, and caching - #13
Merged
Merged
Conversation
Plan every Update All edit from the current document so a line inserted during the registry lookup cannot move a safe bump. Compare versions with PEP 440, accept extras-only requirements files, normalize cache keys, and drop closed documents from the status bar. Co-authored-by: cookabc <chuangcius@gmail.com>
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.
Fixes the five medium-priority items left after #12. No new dependencies; PEP 440 lives in this repo.
npm test(161 passing),biome check, andnpx @vscode/vsce packageall succeed.1. Update All used stale line numbers for safe edits
Issue. Safe updates were turned into
WorkspaceEdits inside the registry loop, using line numbers from the parse taken before the network requests. Only risky updates were re-located afterwards, so an insert or delete while versions were loading moved a patch bump onto the wrong line.Fix. Both safe and risky updates are collected as data. After the confirmation dialog,
planRelocatedEditsreparses the current document and matches each dependency by package name and extra, then plans the rewrite from that line. A dependency that disappeared is skipped.Tests.
src/test/unit/batchUpdate.test.ts2. Debug logging on every CodeLens resolve
Issue.
resolveCodeLenscalledconsole.error("[UAT-PROBE] ...")on every lens.Fix. The probe is removed.
Tests.
mediumReview.test.tsspies onconsole.errorduringresolveCodeLensand asserts the probe string is absent.3. Extras-only requirements files were rejected
Issue.
detectFileTypetreated any[]pair as invalid TOML-like content. A requirements file whose only lines were extras, such asrequests[security]>=2.0, was classified invalid and produced no dependencies.Fix. A
requirements*.txtfile is valid unless it actually contains pyproject markers ([project],[tool., and so on). The content heuristic also allows an extra between the name and the operator, so the same line is recognized without a requirements file name.Tests.
parser.test.ts:requirements.txtcontaining onlyrequests[security]>=2.0is a valid requirements filebasic.test.ts: that file parses both extras lines, anddeps.txtwith onlyrequests[security,socks]>=2.0is detected and parsed4. PEP 440 comparison gaps
Issue.
1.0.0rc1.post1compared greater than1.0.0because anypostsegment was treated as a final post-release. Epochs (1!1.0) were ignored.1.0rc1+cpuwas not a pre-release because the check required the pre tag to be at the end of the string.Fix.
src/core/pep440.tsparses and orders versions with the PEP 440 key(epoch, release, pre, post, dev, local). A pre-release that also has a post or local segment stays a pre-release.==ignores a local version unless the specifier itself has one.~=and.*require the same epoch. An epoch change is a major/high-risk update. The implementation is local to this extension (about 80 KB packaged, no added dependency).Tests.
versionResolver.test.tsandversionAnalyzer.test.ts1.0.0rc1.post1<1.0.0and >1.0.0rc11!1.0>2.0, and resolve picks the highest epoch1.0rc1+cpuis a pre-release;1.0+cpuis notc/rc/pre,1.0-1/1.0.post1,v1.0.0) compare equal==and.*honor epochs;==1.2.3matches1.2.3+cpubut==1.2.3+cpudoes not match1.2.3+gpu1.0.0→1!1.0.0is a high-risk major update5. Cache identity, closed documents, and hover
Issue. Cache keys were only lowercased, so
foo_barandfoo-bardid not share an entry (PEP 503).dependencyCachenever dropped closed documents, and the status bar summed every document ever opened. Hover calledgetLatestCompatiblewith an empty specifier, so it showed the absolute latest while the CodeLens stayed inside the range.Fix. Both the persisted cache and the CodeLens version cache use
versionCacheKey(lowercase, runs of-_.collapsed to one-). Closing a document callsforgetDocument, and the status bar only counts documents still inworkspace.textDocuments. Reopening a file whose versions are already cached refreshes the total. Hover passes the dependency specifier through the sameresolveLatestpath as the CodeLens (a bare==pin still suggests the absolute latest; a range does not).Tests.
mediumReview.test.tsFoo_Bar,foo.bar, andfoo-barshare one registry fetch ingetPackageVersionsand in the CodeLens memory cachetextDocumentsis evicted on the next refreshrequests>=2.0,<3reports2.9.0, not4.0.0; hover onrequests==2.0.0reports4.0.0, matching the CodeLens pin rule