Skip to content

Workspace.remove_folder performs the same deletion twice #613

@meymchen

Description

@meymchen

Component

pygls/workspace/workspace.py

Summary

remove_folder calls pop(..., None) and then immediately attempts del on the same key, which is entirely redundant. Both operations are attempted and two unquote calls are made for the same value.

Expected Behavior

A single removal operation.

Actual Behavior

Two removals and two unquote calls.

Affected Code (pygls/workspace/workspace.py, ~L211-216)

def remove_folder(self, folder_uri: str):
    self._folders.pop(unquote(folder_uri), None)
    try:
        del self._folders[unquote(folder_uri)]
    except KeyError:
        pass

Proposed Fix

Delete the del block; keep only the pop.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions