question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

Python syntax highlighting in a code block is inconsistent (again)

See original GitHub issue

šŸ› Bug Report

Python syntax highlighting in a code block is inconsistent. If this looks familiar, itā€™s because itā€™s just like #2655 (regression).

To Reproduce

Add this block:

@dataclass
class MySQLConfig:
    host: str = "localhost"
    port: int = 3306

@dataclass
class Config:
    db: MySQLConfig = MySQLConfig()
    verbose: bool = True

cfg_store = ConfigStore.instance()
cfg_store.store(name="config", node=MyConfig)

@hydra.main(config_name="config")
def my_app(cfg: MyConfig) -> None:
    # Python knows that the type of cfg.db is MySQLConfig without any additional hints
    print(f"Host: {cfg.db.host}, port: {cfg.db.port}")

if __name__ == "__main__":
    my_app()

Expected behavior

Syntax highlighting is applied consistently.

Actual Behavior

See screen shot, only the first @dataclass annotation is highlighted.

image

Your Environment

Ubuntu 18.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:9

github_iconTop GitHub Comments

1reaction
slorbercommented, Jun 29, 2020

Iā€™ve made a PR to your repo: https://github.com/facebookresearch/hydra/pull/730

And opened an issue on prism-react-render, not sure whatā€™s happening exactly: https://github.com/FormidableLabs/prism-react-renderer/issues/87

0reactions
lex111commented, Jun 10, 2021

It seems that this is no longer relevant, so Iā€™m closing this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Syntax highlighting is not consistent - Meta Stack Overflow
For Python, the answer is that the lines must be indented four spaces. Then they will be picked up as code lines.
Read more >
Changes to syntax highlighting - Meta Stack Exchange
code blocks are never highlighted (Super User, photo.se, bicycles.se, etc). We are now moving to a more tag-based syntax highlighting method.
Read more >
Syntax highlighting : r/neovim - Reddit
I tried tree-sitter as a solution, but the highlighting is all over the place and inconsistent. On top of being inconsistent it makes...
Read more >
Invalid Syntax in Python: Common Reasons for SyntaxError
The solution to this is to make all lines in the same Python code file use either tabs or spaces, but not both....
Read more >
A case against syntax highlighting - Linus ƅkesson
All other colors are used for special things like highlighting enums, classes etc. or placing a grey background behind the parts of the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found