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 custom formatters #1733

Merged
merged 6 commits into from
Nov 24, 2023
Merged

Conversation

denisart
Copy link
Contributor

@denisart denisart commented Nov 23, 2023

Hooks in other libs: https://the-guild.dev/graphql/codegen/docs/config-reference/lifecycle-hooks

it is beta version of custom code formatters. it is simple realization without lifecycle hooks. Only before code generation

See docs/custom-formatters.md for simple usage example. And see test_format.py for development examples.

What do you think about this idea?

Copy link

codecov bot commented Nov 23, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (main@ef1f97e). Click here to learn what that means.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1733   +/-   ##
=======================================
  Coverage        ?   99.05%           
=======================================
  Files           ?       37           
  Lines           ?     4110           
  Branches        ?      954           
=======================================
  Hits            ?     4071           
  Misses          ?       25           
  Partials        ?       14           
Flag Coverage Δ
unittests 98.73% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

codspeed-hq bot commented Nov 23, 2023

CodSpeed Performance Report

Merging #1733 will not alter performance

Comparing denisart:add-custom-formatters (6973900) with main (ef1f97e)

Summary

✅ 29 untouched benchmarks

@koxudaxi
Copy link
Owner

@denisart
Thank you for creating the PR.
We need the feature to use another formatter. We have the feature request. #621

This PR provides a flexible way to pass the formatter.
But, can we give the preset formatter like ruff? #1643
(I want to change the default formatter to ruff. Because black spend time in the process.)
image https://codspeed.io/koxudaxi/datamodel-code-generator/branches/denisart:add-custom-formatters

I expect the CLI arguments will be added in the future.

--preset-formatter-python [ruff, black-isort]
or 
--preset-formatter [ruff, black-isort, gofmt]

@denisart
Copy link
Contributor Author

But, can we give the preset formatter like ruff?

I agree with the ruff as default (if user not specified formatters). Do you want to work on this PR or as part of a new PR?

@koxudaxi
Copy link
Owner

@denisart

I agree with the ruff as default (if user not specified formatters). Do you want to work on this PR or as part of a new PR?

Thank you for asking.
I don't expect to set ruff as default soon. Because I guess the changes will affect many users.
But, I prefer to introduce ruff option as preset.

This project is used by many projects. I want to avoid breaking changes in the short term. (including adding dependency )

@denisart
Copy link
Contributor Author

denisart commented Nov 24, 2023

I want to avoid breaking changes in the short term.

I agree with you. So i added graphql-core as optional dependency.

@denisart
Copy link
Contributor Author

@koxudaxi
Do we have any undiscussed issues about this PR?

Copy link
Owner

@koxudaxi koxudaxi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@koxudaxi koxudaxi merged commit a36ce94 into koxudaxi:main Nov 24, 2023
@denisart denisart deleted the add-custom-formatters branch November 24, 2023 16:01
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

Successfully merging this pull request may close these issues.

2 participants