GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Prevent creating empty .ropeproject with null conf by karimbenbourenane · Pull Request #664 · python-lsp/python-lsp-server

Conversation

@karimbenbourenane

@karimbenbourenane karimbenbourenane commented Jul 30, 2025

Copy link
Copy Markdown

When ropeFolder is defined in the configuration but set to null (as would happen with a default config generated by e.g. Zed editing a python file), avoid creating an empty and unused .ropeproject directory. This change completes what I think was the goal of https://github.com/python-lsp/python-lsp-server/pull/604/files, where "ropeFolder": null in the configuration still generates an empty and unused .ropeproject folder.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@karimbenbourenane
Prevent creating empty .ropeproject with null conf
80afb86
@ccordoba12

ccordoba12 commented Jul 30, 2025

Copy link
Copy Markdown
Member

Hey @karimbenbourenane, thanks for your contribution! I have a quick question for you: how is this different from #604?

Also, pinging @osiewicz about this (the author of #604). What do you think about this one?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@osiewicz

osiewicz commented Jul 30, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

I sketched up a quick example of playground, but I feel like that'd regress us to before #604 (where you wouldn't be able to pass in null?)?
https://www.online-python.com/Qg4WIZrYfk
I guess the bug might be in Zed and not in pylsp.

ccordoba12 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@karimbenbourenane

karimbenbourenane commented Jul 31, 2025

Copy link
Copy Markdown
Author

Hey @karimbenbourenane, thanks for your contribution! I have a quick question for you: how is this different from #604?

Also, pinging @osiewicz about this (the author of #604). What do you think about this one?

It's different in that, the default configuration with zed will be "ropeFolder": null. In #604, this means that despite an explicitly stated null ropeFolder, it will generate an empty and unused .ropeproject directory any time the pylsp is used for example editing a python file. The change I submitted does not do that.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@karimbenbourenane

karimbenbourenane commented Jul 31, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Author

@ccordoba12 see the case where rope_config = {"ropeFolder": None}

In #604 the condition passes and the .ropeproject ends up getting generated anyway because of Project(self._root_path, ropefolder=None) being executed. In this proposed change (#664) None does not get passed as a named argument for ropeFolder when "ropeFolder" is a key in the rope_config with value set to None.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@osiewicz

osiewicz commented Aug 1, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

We do want to pass in None as a ropefolder argument though, as that's what disables creation of a Rope cache.. Please see: https://github.com/python-rope/rope/blob/a32584f5742c093b10437f8da13bfefddb19c155/rope/base/project.py#L260 and the constructor:
https://github.com/python-rope/rope/blob/a32584f5742c093b10437f8da13bfefddb19c155/rope/base/project.py#L198C45-L198C55
https://github.com/python-rope/rope/blob/a32584f5742c093b10437f8da13bfefddb19c155/rope/base/project.py#L227
https://github.com/python-rope/rope/blob/a32584f5742c093b10437f8da13bfefddb19c155/rope/base/project.py#L259

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@AdamOlczak

AdamOlczak commented Sep 4, 2025

Copy link
Copy Markdown

@osiewicz I've done some digging into this issue and while I can confirm the issue exists here in pylsp, I don't agree with the proposed reason and solution for this issue by @karimbenbourenane.

As you mentioned and tested by you, it would probably regress to before #604.

I did test it and it seems that when the rope_config is being accessed in _rope_project_builder it doesn't have ropeFolder key at all, only the plugins

python-lsp-server/pylsp/workspace.py

Line 80 in 89265cd

rope_folder = rope_config.get("ropeFolder")

Tracing it back to where the settings are being updated I found that Config.settings method returns incorrect settings object.
Specifically this line:

python-lsp-server/pylsp/config/config.py

Lines 149 to 150 in 89265cd

# LSP configuration
settings = _utils.merge_dicts(settings, self._settings)

_settings dict contains correct configuration as requested by the LSP client, with ropeFolder: None, however call to _utils.merge_dicts returns the dict without ropeFolder causing an issue.

To confirm this, I've logged the value using this snippet:

        # LSP configuration
        log.debug(f"{settings=}")
        log.debug(f"{self._settings=}")
        settings = _utils.merge_dicts(settings, self._settings)
        log.debug(f"{settings=}")

giving me the following result:

2025-09-05 00:24:12,887 CEST - DEBUG - pylsp.config.config - settings={'plugins': {'flake8': {'enabled': False}, 'pylint': {'enabled': False, 'args': [], 'executable': None}, 'rope_autoimport': {'enabled': False, 'memory': False, 'completions': {'enabled': True}, 'code_actions': {'enabled': True}}, 'pydocstyle': {'enabled': False}, 'preload': {'modules': ['OpenGL', 'PIL', 'array', 'audioop', 'binascii', 'cPickle', 'cStringIO', 'cmath', 'collections', 'datetime', 'errno', 'exceptions', 'gc', 'imageop', 'imp', 'itertools', 'marshal', 'math', 'matplotlib', 'mmap', 'mpmath', 'msvcrt', 'networkx', 'nose', 'nt', 'numpy', 'operator', 'os', 'os.path', 'pandas', 'parser', 'rgbimg', 'scipy', 'signal', 'skimage', 'sklearn', 'statsmodels', 'strop', 'sympy', 'sys', 'thread', 'time', 'wx', 'xxsubtype', 'zipimport', 'zlib']}, 'pylsp_mypy': {}, 'rope_completion': {'enabled': False, 'eager': False}}, 'rope': {'extensionModules': ['OpenGL', 'PIL', 'array', 'audioop', 'binascii', 'cPickle', 'cStringIO', 'cmath', 'collections', 'datetime', 'errno', 'exceptions', 'gc', 'imageop', 'imp', 'itertools', 'marshal', 'math', 'matplotlib', 'mmap', 'mpmath', 'msvcrt', 'networkx', 'nose', 'nt', 'numpy', 'operator', 'os', 'os.path', 'pandas', 'parser', 'rgbimg', 'scipy', 'signal', 'skimage', 'sklearn', 'statsmodels', 'strop', 'sympy', 'sys', 'thread', 'time', 'wx', 'xxsubtype', 'zipimport', 'zlib']}}
2025-09-05 00:24:12,887 CEST - DEBUG - pylsp.config.config - self._settings={'plugins': {'pycodestyle': {'enabled': False}, 'rope_autoimport': {'enabled': True, 'memory': True}, 'pylsp_mypy': {'enabled': False, 'overrides': ['--python-executable', '/nix/store/v72ywdz0dd2d6sb3knymx9ww8r6pcqba-python3-3.13.5/bin/python', '--cache-dir=/dev/null', True]}, 'jedi': {'environment': '/nix/store/v72ywdz0dd2d6sb3knymx9ww8r6pcqba-python3-3.13.5/bin/python'}}, 'rope': {'ropeFolder': None}}
2025-09-05 00:24:12,887 CEST - DEBUG - pylsp.config.config - settings={'plugins': {'flake8': {'enabled': False}, 'pycodestyle': {'enabled': False}, 'pylint': {'enabled': False, 'args': [], 'executable': None}, 'jedi': {'environment': '/nix/store/v72ywdz0dd2d6sb3knymx9ww8r6pcqba-python3-3.13.5/bin/python'}, 'rope_completion': {'enabled': False, 'eager': False}, 'rope_autoimport': {'memory': True, 'code_actions': {'enabled': True}, 'enabled': True, 'completions': {'enabled': True}}, 'pydocstyle': {'enabled': False}, 'preload': {'modules': ['OpenGL', 'PIL', 'array', 'audioop', 'binascii', 'cPickle', 'cStringIO', 'cmath', 'collections', 'datetime', 'errno', 'exceptions', 'gc', 'imageop', 'imp', 'itertools', 'marshal', 'math', 'matplotlib', 'mmap', 'mpmath', 'msvcrt', 'networkx', 'nose', 'nt', 'numpy', 'operator', 'os', 'os.path', 'pandas', 'parser', 'rgbimg', 'scipy', 'signal', 'skimage', 'sklearn', 'statsmodels', 'strop', 'sympy', 'sys', 'thread', 'time', 'wx', 'xxsubtype', 'zipimport', 'zlib']}, 'pylsp_mypy': {'overrides': ['--python-executable', '/nix/store/v72ywdz0dd2d6sb3knymx9ww8r6pcqba-python3-3.13.5/bin/python', '--cache-dir=/dev/null', True], 'enabled': False}}, 'rope': {'extensionModules': ['OpenGL', 'PIL', 'array', 'audioop', 'binascii', 'cPickle', 'cStringIO', 'cmath', 'collections', 'datetime', 'errno', 'exceptions', 'gc', 'imageop', 'imp', 'itertools', 'marshal', 'math', 'matplotlib', 'mmap', 'mpmath', 'msvcrt', 'networkx', 'nose', 'nt', 'numpy', 'operator', 'os', 'os.path', 'pandas', 'parser', 'rgbimg', 'scipy', 'signal', 'skimage', 'sklearn', 'statsmodels', 'strop', 'sympy', 'sys', 'thread', 'time', 'wx', 'xxsubtype', 'zipimport', 'zlib']}}

I didn't investigate, as of now, why merge_dicts is returning the new dict as it is. It's too late for me to do that today.

osiewicz and friday reacted with heart emoji
All reactions
  • ❤️ 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

AdamOlczak added a commit to AdamOlczak/python-lsp-server that referenced this pull request Sep 7, 2025
@AdamOlczak
Include None value from second object while merging dicts (python-lsp…
1c746be
…#622, python-lsp#664)
@AdamOlczak AdamOlczak mentioned this pull request Sep 7, 2025
Include None value from second object while merging dicts #670
Open
@AbhiramVSA AbhiramVSA mentioned this pull request Oct 30, 2026
Schema appears incorrect for rope.extensionModules #590
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@karimbenbourenane @ccordoba12 @osiewicz @AdamOlczak
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.