Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling monorepo setup #345

Closed
jarikujansuu opened this issue Jan 5, 2024 · 2 comments
Closed

Handling monorepo setup #345

jarikujansuu opened this issue Jan 5, 2024 · 2 comments

Comments

@jarikujansuu
Copy link

Describe the bug

We got a monorepo setup so in a single repository we have multiple Python projects attached to it, so something like this

/ --- root is not a Python project but Typescript CDK project
/service/X --- dockerised service
/lambda/A. --- bunch of AWS Lambdas
/lambda/B
/lambda/C
....
So all of those are separate Python setups with their own environments, all should have the same formatting rules

I tried enabling the Ruff plugin and the formatting feature and tested with that service "X". Without pointing to any configs it formatted the file with default settings instead of reading the current configs from the module pyproject.toml file.

If I then point the config file to service/X/pyproject.toml the code is formatted correctly but it doesn't recognize which are 3rd party and which are my imports so imports are moved to the wrong order

We have in pyproject.toml the following section, which doesn't seem to have any effect here

[tool.ruff.isort]
combine-as-imports = true
known-first-party = ["src", "tests"]

If I open the subproject (service/X) instead the root of the repository formatting seems to work correctly, so it reads the line length from pyproject.toml and also knows which are own and which are 3rd party imports

Expected behavior
The plugin should read the configs from the subproject even if open the repository root in Pycharm.

Environments (please complete the following information):

  • IDE: [PyCharm Professional 2023.2.3 ]
  • OS: [macOS 14.1]
  • Ruff Version [0.1.6 ]
  • Plugin version [0.0.27 ]
@koxudaxi
Copy link
Owner

@jarikujansuu
Thank you for creating the issue.

First, does ruff by itself without this plugin load the configuration file as expected?
Because if you read here, ruff will properly go to load the closest pyproject.toml, so I don't think there is any need to do any detailed configuration here.
https://docs.astral.sh/ruff/configuration/#config-file-discovery
Unless you specify the config file path in the plugin configuration, the plugin will just run ruff from the project root.

@koxudaxi
Copy link
Owner

@jarikujansuu
I have fixed the version 0.0.29
Thank you very much!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants