Tony
Tony

Reputation: 139

Is this a bug for Even Better TOML VS Code extension?

The directory structure.

dir1/
|-- helloworld/
    |-- __init__.py
    |-- hello.py
|-- pyproject.toml
|-- setup.py

setup.py

from setuptools import setup, find_packages

setup(
    name="helloworld",                     # Package name
    version="0.1.0",                    # Versioning (Semantic Versioning recommended)
    packages=find_packages()
)

Error message: {"name":"helloworld"} is not valid under any of the given schemas Even Better TOML

pyproject.toml

[build-system]
requires = ["setuptools>=42", "wheel"]
build-backend = "setuptools.build_meta"

[tool.setuptools]
packages = ["helloworld"]
package-dir = {"" = "helloworld"}

[project] #<--- Error message
name = "helloworld"

When Even Better TOML is installed and enable, the error message appears. OS is window.

Upvotes: 1

Views: 866

Answers (2)

LoHer
LoHer

Reputation: 189

Update: As of December 20th, 2024, the actual VS Code extension Even Better TOML will be updated again and receives new JSON schemas from the JSON schema store. Therefore, the release fork is both not needed and not available anymore.


TLDR: Please install the VS Code extension Even Betterer TOML (Release Fork) and deactivate the "Even Better TOML" extension.


Longer Answer:

The "Even Better TOML" extension isn't updated since 2023-07-15, because a CI token is expired and the only maintainer with access is not available: see discussion on GitHub.

Therefore, a release fork was created and published under the name Even Betterer TOML (Release Fork).

In each release of the extension, all schemas from the JSON schema store are included. The schema store contains the schema for the PEP 621 compliant pyproject.toml file for a while now. In the lastest update of the new VS Code extension, the schema is included and the error message will disappear.

Upvotes: 0

Abel Cheung
Abel Cheung

Reputation: 526

Oh my. OP, comments and answers have all gone wrong.

The OP part

Even Better TOML has done its job properly by pointing out lack of mandatory setting in [project] table. The official spec mandates both name and version keys for [project]:

[project]
name = 'helloworld'
version = '0.1'

However, you choose either setup.py or pyproject.toml to specify your project metadata, not both. If you have picked setup.py, then pyproject.toml shouldn't have [project] section at all. However, pyproject.toml is the future way to go.

The Comment part

I tried disabling the extension and installing TOML Language Support and with that one I don't have any issue.

TOML Language Support doesn't have issue because it doesn't validate pyproject.toml at all. It only does the bare minimum validation against generic TOML structure.

The answer part

While it's true that Even Better TOML lacks maintenance and the newer fork does better job, previous answer has totally nothing to do with OP's problem. Any extension that doesn't report problem with OP's pyproject.toml IS faulty.

Upvotes: 2

Related Questions