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

Add pyproject.toml / setup.py configuration #72

Open
SerGeRybakov opened this issue May 17, 2022 · 3 comments · May be fixed by #84
Open

Add pyproject.toml / setup.py configuration #72

SerGeRybakov opened this issue May 17, 2022 · 3 comments · May be fixed by #84
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@SerGeRybakov
Copy link

Hi!
Though I use ssort in pre-commit and CI I think it will be nice to have a possibility to set up ssort configuration in default pyproject.toml / setup.py files.
There one can explicitly exclude some folders or files from ssorting, set the ordering and all other other possible cli-configs.
Is it possible?

@bwhmather
Copy link
Owner

Hi @SerGeRybakov - Sorry for slow response. Glad to hear you are using ssort. Ordering isn't really configurable in any way at the moment, and I'm hesitant to change that. Excluding folders and files based on pyproject.toml would definitely be possible though, and something I would be glad to have in the project. At the moment we exclude based on .gitignore. I think you would probably need to extend this function to also find, parse and cache pyproject.toml files:

def is_ignored(path: str | os.PathLike) -> bool:
# Can't use pathlib.Path.resolve() here because we want to maintain
# symbolic links.
path = pathlib.Path(os.path.abspath(path))
for part in (path, *path.parents):
patterns = _get_ignore_patterns(part)
if patterns.match_file(path.relative_to(part)):
return True
if _is_project_root(part):
return False
return False
.

A related issue is #62. It might make sense to also have pyproject.toml change the default behaviour when running ssort in a folder without arguments.

I'm a bit snowed under at the moment, so won't be able to implement any time soon. I'm going to mark this as good first issue. If you want to take a stab at it, I will happily review.

@bwhmather bwhmather added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels May 24, 2022
@cgahr
Copy link
Collaborator

cgahr commented Apr 26, 2023

I'm implementing this

@cgahr cgahr linked a pull request Apr 26, 2023 that will close this issue
9 tasks
@cgahr
Copy link
Collaborator

cgahr commented Apr 30, 2023

Closed by #84

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants