Skip to content

[Bug] formatting does not work if robotcode.robocop.configFile is specified #469

@d-biehl

Description

@d-biehl

Type: Bug

if robotcode.robocop.configFile is specified in settings, formatting does not work with robocop version 6.

object has no attribute 'open'
Traceback (most recent call last):
  File "/Users/daniel/Develop/robot/robotcode/packages/core/src/robotcode/core/event.py", line 85, in _notify
    yield method(*__args, **__kwargs)
          ~~~~~~^^^^^^^^^^^^^^^^^^^^^
  File "/Users/daniel/Develop/robot/robotcode/packages/language_server/src/robotcode/language_server/robotframework/parts/formatting.py", line 78, in format
    return self.format_robocop(document, options, **further_options)
           ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/daniel/Develop/robot/robotcode/packages/language_server/src/robotcode/language_server/robotframework/parts/formatting.py", line 206, in format_robocop
    config_manager = ConfigManager(
        [document.uri.to_path()],
    ...<3 lines>...
        ignore_file_config=robocop_config.ignore_file_config,
    )
  File "/Users/daniel/Develop/robot/robotcode/tests/robotcode/language_server/robotframework/parts/data/.venv/lib/python3.13/site-packages/robocop/config.py", line 749, in __init__
    self.default_config: Config = self.get_default_config(config)
                                  ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
  File "/Users/daniel/Develop/robot/robotcode/tests/robotcode/language_server/robotframework/parts/data/.venv/lib/python3.13/site-packages/robocop/config.py", line 765, in get_default_config
    configuration = files.read_toml_config(config_path)
  File "/Users/daniel/Develop/robot/robotcode/tests/robotcode/language_server/robotframework/parts/data/.venv/lib/python3.13/site-packages/robocop/files.py", line 29, in read_toml_config
    config = load_toml_file(config_path)
  File "/Users/daniel/Develop/robot/robotcode/tests/robotcode/language_server/robotframework/parts/data/.venv/lib/python3.13/site-packages/robocop/files.py", line 16, in load_toml_file
    with config_path.open("rb") as tf:
         ^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'open'

Extension version: 1.3.0
VS Code version: Code 1.101.1 (Universal) (18e3a1ec544e6907be1e944a94c496e302073435, 2025-06-18T13:35:12.605Z)
OS version: Darwin arm64 24.5.0
Modes:

Python Version: 3.13.4 Venv
RobotFramework Version: 7.3
Additional tools: robotframework-robocop==6.4.0,

System Info
Item Value
CPUs Apple M4 Max (16 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: enabled_on
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) 2, 2, 2
Memory (System) 64.00GB (1.99GB free)
Process Argv --crash-reporter-id 7b195826-a430-422f-b11f-988245f30283
Screen Reader no
VM 0%
A/B Experiments
vspor879:30202332
vspor708:30202333
vspor363:30204092
binariesv615:30325510
c4g48928:30535728
962ge761:30959799
pythontbext0:30879054
cppperfnew:31000557
pythonrstrctxt:31112756
5fd0e150:31155592
dwcopilot:31170013
6074i472:31201624
dwoutputs:31242946
customenabled:31248079
pythoneinst12:31285622
bgtreat:31268568
4gafe986:31271826
c7cif404:31314491
996jf627:31283433
usemplatestapi:31297334
7bj51361:31289155
aj953862:31281341
generatesymbolt:31295002
convertfstringf:31295003

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions