Implementing Ruff linter in Gitlab CI/CD for Databrick notebooks

bomb_omb
New Contributor II

Hi all, I am trying to implement ruff linting in Gitlab CI/CD where I am only trying to catch undefined name errors ["F821"]. However it is picking up my magic commands like %sql and %pip as syntax errors and I am unable to exclude it in the pyproject.toml file.

When using %run to import functions from another notebook it will not recognise it as an import. 

Has anyone tried to implement ruff in CI/CD and if so how did you get through this hurdle? Thanks!

saurabh18cs
Esteemed Contributor

you're using ruff for linting. The issue with Databricks magic commands (%sql, %pip, %run) is that they're Databricks-specific syntax, not standard Python, so ruff treats them as errors. you should exclude databricks notebook from ruff.

View solution in original post