Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression in sendToRepl - incorrectly passes selected text to repl #24064

Closed
dangets opened this issue Sep 6, 2024 · 3 comments
Closed

Regression in sendToRepl - incorrectly passes selected text to repl #24064

dangets opened this issue Sep 6, 2024 · 3 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug triage-needed Needs assignment to the proper sub-team

Comments

@dangets
Copy link

dangets commented Sep 6, 2024

Type: Bug

Behaviour

With Python extension version v2024.12.3 I am able to select the block and send the below snippet to the repl successfully. With version v2024.14.0 the same process adds some newlines and incorrectly splits the class and I receive many IndentationError errors in the repl.

I have python.REPL.enableREPLSmartSend set to false, but setting it back to true has the same effect, with or without the text selected.

Steps to reproduce:

  1. Use version v2024.14.0
  2. Copy the below code snippet into a python file
  3. Select the text, and use the Shift + Enter to send the code to the repl


class TfcClient:
    def __init__(self):
        self.base_url = "https://app.terraform.io/api/v2/"
        self.org = "my_org"
        self.tokens = [TFC_API_TOKEN]
        self.my_throttler = throttler.Throttler(rate_limit=15)

    def get_workspaces(self, page_size=100, estimated_num_pages=1):
        async def _get_workspace_page(page_size: int, page_num: int, client: httpx.AsyncClient):
            url = self.base_url + f"organizations/{self.org}/workspaces"
            params = {}
            params["page[size]"] = page_size
            params["page[number]"] = page_num
            headers = {
                "Authorization": f"Bearer {self.tokens[0]}",
                "Content-Type": "application/vnd.api+json",
            }
            async with self.my_throttler:
                r = await client.get(url=url, headers=headers, params=params)
                r.raise_for_status()
                json = r.json()
                return json['data']

        async def _get_workspaces(page_size, estimated_num_pages=1):
            """assumes sequential page numbering"""
            async with httpx.AsyncClient(timeout=30) as client:
                eager_tasks = [_get_workspace_page(page_size=page_size, page_num=i, client=client) for i in range(1, estimated_num_pages + 1)]
                workspaces = []
                for task in asyncio.as_completed(eager_tasks):
                    try:
                        page_list = await task
                        workspaces.extend(page_list)
                    except httpx.HTTPStatusError as e:
                        if e.response.status_code != 404:
                            raise e

                page_num = estimated_num_pages + 1
                while True:
                    page_list = await _get_workspace_page(page_size=page_size, page_num=page_num, client=client)
                    if not page_list:
                        break
                    workspaces.extend(page_list)
                    page_num += 1

                return workspaces

        return asyncio.run(_get_workspaces(page_size, estimated_num_pages))

    def get_projects(self, page_num=1):
        url = f"{self.base_url}organizations/{self.org}/projects"
        with requests.session() as s:
            params = {}
            params["page[size]"] = 100
            params["page[number]"] = page_num
            headers = {
                "Authorization": f"Bearer {TFC_API_TOKEN}",
                "Content-Type": "application/vnd.api+json",
            }

            r = s.get(url=url, headers=headers, params=params)
            r.raise_for_status()
            body = r.json()
            if body['meta']['pagination']['next-page'] is not None:
                raise ValueError("unhandled pagination on projects")
            data = body['data']
            return [
                Project(project_id=d['id'], name=d['attributes']['name'])
                for d in data
            ]

Extension version: 2024.14.0
VS Code version: Code 1.93.0 (Universal) (4849ca9bdf9666755eb463db297b69e5385090e3, 2024-09-04T13:02:38.431Z)
OS version: Darwin arm64 23.6.0
Modes:

  • Python version (& distribution if applicable, e.g. Anaconda): 3.12.2
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv
  • Value of the python.languageServer setting: Pylance
User Settings


venvFolders: "<placeholder>"

languageServer: "Pylance"

Installed Extensions
Extension Name Extension Id Version
Docker ms-azuretools.vscode-docker 1.29.2
EditorConfig for VS Code EditorConfig.EditorConfig 0.16.4
Elixir snippets florinpatrascu.vscode-elixir-snippets 0.2.51
ElixirLS: Elixir support and debugger JakeBecker.elixir-ls 0.23.1
Even Better TOML tamasfe.even-better-toml 0.19.2
GitLens — Git supercharged eamodio.gitlens 15.4.0
Go golang.go 0.42.0
HashiCorp HCL hashicorp.hcl 0.5.0
HashiCorp Terraform hashicorp.terraform 2.32.3
JavaScript Debugger ms-vscode.js-debug 1.93.0
JavaScript Debugger Companion Extension ms-vscode.js-debug-companion 1.1.3
LDAP Explorer fengtan.ldap-explorer 1.3.2
Pylance ms-python.vscode-pylance 2024.8.2
Python ms-python.python 2024.12.3
Python Debugger ms-python.debugpy 2024.10.0
Rainbow CSV mechatroner.rainbow-csv 3.12.0
Ruff charliermarsh.ruff 2024.44.0
Table Visualizer for JavaScript Profiles ms-vscode.vscode-js-profile-table 1.0.9
Vim vscodevim.vim 1.28.0
YAML redhat.vscode-yaml 1.15.0
System Info
Item Value
CPUs Apple M3 Pro (11 x 2400)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) 2, 2, 3
Memory (System) 36.00GB (0.14GB free)
Process Argv . --crash-reporter-id 58c730cb-90f8-44fa-a353-d046d652ec7f
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805:30301674
binariesv615:30325510
vsaa593cf:30376535
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
962ge761:30959799
pythongtdpath:30769146
welcomedialogc:30910334
pythonnoceb:30805159
asynctok:30898717
pythonmypyd1:30879173
2e7ec940:31000449
pythontbext0:30879054
accentitlementst:30995554
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
dsvsc021:30996838
bdiig495:31013172
a69g1124:31058053
dvdeprecation:31068756
dwnewjupytercf:31046870
impr_priority:31102340
refactort:31108082
pythonrstrctxt:31112756
wkspc-onlycs-t:31132770
wkspc-ranged-c:31125598
pme_test_c:31118331
ei213698:31121563

error-v2024.14.0
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Sep 6, 2024
@karthiknadig karthiknadig added the bug Issue identified by VS Code Team member as probable bug label Sep 9, 2024
@thunfischtoast
Copy link

thunfischtoast commented Sep 10, 2024

This seems to be related to this issue: #24083 and #24064

I could replicate your problem and solve it in the same way by downgrading the extension to v2024.12.3

@adamrickayzenanvil
Copy link

This seems to be related to this issue: #24083 and #24064

I could replicate your problem and solve it in the same way by downgrading the extension to v2024.12.3

You legend, this worked. Thank you

@anthonykim1
Copy link

@dangets Thanks for filing this issue and @thunfischtoast Thanks for helping out here - Yes, I also think it is related to #24064. We may have to roll back #23977 - Anyways, lets track this in one place #24064

@anthonykim1 anthonykim1 closed this as not planned Won't fix, can't repro, duplicate, stale Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

5 participants