Made some notes on auto-formatting YAML files using yamlfmt (the YAML equivalent of Black and Prettier)

https://til.simonwillison.net/yaml/yamlfmt

Auto-formatting YAML files with yamlfmt

I decided to see if there was an equivalent of Black or Prettier for YAML files. I found yamlfmt from Google.

@simon Looks like something worth trying in pre-commit, though I’ve also found prettier’s YAML formatting perfectly acceptable.

@adamchainz @simon I came here to say this too.

pre-commit is 100% worth learning. A nice bonus is that it'll manage installing/updating/upgrading ruff, black, and others so that you don't have to anymore.

Plus, you get auto-formatting for free(ish).

I would put it on my "stop what you are doing and learn it today" list if you were asking 😄

@webology @adamchainz @simon anything else to add to the "stop what you are doing and learn it today" list?

Asking for a friend

@mucio @adamchainz @simon I would put just/justfiles on that list too because it's the best parts of Make (that I like), but it works anywhere. https://github.com/casey/just

Several years ago, I standardized my project workflows so getting back up to speed or making quite fixes is easy peasy with it.

GitHub - casey/just: 🤖 Just a command runner

🤖 Just a command runner. Contribute to casey/just development by creating an account on GitHub.

GitHub

@mucio (- letting Adam and Simon off at that last stop)

I would consider TailwindCSS's typography aka "prose" plugin to be one hell of a life hack too. https://tailwindcss.com/docs/typography-plugin

It's one CSS class you add and it totally transforms your page. I use it with markdown on a ton of projects.

I struggled with it until I realized I could undo/customize it too. Now I use it everywhere.

https://tailwindcss.com/docs/typography-plugin#undoing-typography-styles

@tailwindcss/typography - Tailwind CSS

Beautiful typographic defaults for HTML you don't control.

@mucio I covered all the best workflow-improving tools I know of for Django in my book Boost Your Django DX: https://adamchainz.gumroad.com/l/byddx

New one does the same with Git: https://adamchainz.gumroad.com/l/bygdx

Both cover pre-commit and some tools to run within pre-commit.

Boost Your Django DX

🚀 Updated 17th January 2024 for Django 5.0 and Python 3.12 - see the blog post.During my years working with Django, I’ve picked up many tools and techniques to boost my Developer Experience (DX). This book covers as many of these as possible so you can learn them, too!ContentsThe book contains 12 chapters.Below is a brief summary of the contents - my blog has the full table of contents. For a sample extracted from the settings chapter, see this post.OriginOpening notes, a description of the included examples, acknowledgements, and changelog.DocumentationTools to get you to the right documentation, quicker. Covers DevDocs, DuckDuckGo, Bonus Django Documentation Sites, Wget, and some miscellaneous tips.Virtual Environments and DependenciesManage environments, and the dependencies within, correctly and easily. Covers venv, virtualenv, pip-tools, pip-lock, recommended practices for dependency management, and Python’s development mode.Python ShellEnhance your Python command line experience. Covers IPython and django-read-only.Development ServerMake Django’s runserver better. Covers django-debug-toolbar, Watchman, django-browser-reload, and Rich.Code Quality ToolsThe key tools to improve your code quality. Covers EditorConfig, pre-commit, Black, isort, and Flake8.Further Code Quality ToolsMany extra tools that are useful for Django development. Covers pyupgrade, django-upgrade, pre-commit-hooks, reorder_python_imports, curlylint, DjHTML, Mypy (barely!), Prettier, ESLint, and Shellcheck.Build Your Own ToolsHow to make your own code quality tools. Covers pre-commit’s virtual languages, how to write and test a Flake8 plugin, and how to write a pre-commit-compatible command line tool.SettingsTips and patterns for managing Django’s settings file. Covers structuring your settings, a template, some patterns to avoid, and testing settings files.Models and MigrationsTips and tools for managing your data. Covers writing a management command to seed your development database, generating data with Factory Boy, migration safeguard practices, and django-linear-migrations.System ChecksMake the most of Django’s built-in runtime code quality framework. Covers how system checks work, how to write and test your own checks, and django-version-checks.TerminusClosing notes with links to further reading, including many things that didn't make it into the book.FAQWho are you?Hi, I'm Adam Johnson. I'm an author and solo consultant working with Django and Python.I've used Django since 2012 and have been a member of the Django Project Steering Council since the 2.2 release cycle.Is this an official Django product?The Django Software Foundation didn't help me out with this book, and this is in no way "official". It's a product of A.W.S. (Adam's Web Services) Ltd.You should make a donation to the DSF separately!What's included?A PDF watermarked with your email address, an ePub, an AZW3 file (Kindle), and a resources zip file containing all the code examples.Will you do a printed version?Unfortunately, I can’t afford to do print versions given that I (aim to) update at least every eight months for each new Django version, and the audience is so global.Do you offer any discounts?Gumroad’s purchasing power parity feature will automatically offer you a discount based on your location.Outside of that, I offer occasional seasonal discounts. Follow my blog,Mastodon, or Twitter to be notified of these.Can I get an invoice?Gumroad will send you a receipt with a "generate" button to turn it into an invoice, so you can make your employer pay!Can I purchase with an alternative method (e.g. direct bank transfer)?Due to accounting limitations, I'm only able to sell my product on Gumroad. If it doesn't work for you please try emailing Gumroad support ([email protected]) and CC'ing me.Praise“I learned more from those two books than years of coding in Django”—Nick McCullum on Twitter“Besides “Fluent Python” is “Boosting your Django DX” by @adamchainz my most read #python book. It is such a great book for tooling enthusiasts like me.”—Oliver Andrich on Mastodon“The Django DX book is incredibly helpful to both confirm I am on the "right" path but mostly learning a TON that I'm incorporating into my projects.”—dev jay on Twitter“Just finished your book in one sitting. Really excited to put your wisdom into action!”—Felix Sargent on Twitter“I've been working with @djangoproject for over a decade and still love it, but the hardest thing now is not the framework, but learning how to use it better, how to break old habits, and find new tools and patterns. Really appreciate @AdamChainz "Boost Your Django DX" book, thx!”—@rogerhoward on Twitter“If you experience (software) development or work with those that do, drop whatever you’re doing and buy this book now! Having worked with Adam for the past couple of years, he has improved our developer experience no end at http://ev.energy (and his book on testing is 🔥)”—Chris Darby on Twitter“Used my employer training budget for both of Adam's books, and they are one of the best purchases of my technical books. If you write Django, buy them and thank me later. Reasons for my confidence:- tooling and best practices are hard skills that you can only know how good they are when you know them and use them daily. It saves you hours of unnecessary work, and makes life much easier.- I had the "wow, wish I had known this!" moments almost while reading every page of the book ”—Xuan on Goodreads“I've spent years building Django projects for my clients and I started coaching new developers in Django skills in 2021. This book contains a lot of Adam's hard-won practical tips that would have saved my clients a lot of money. From setting up your environments properly, to code quality tooling, to writing your own flake8 plugins, new Django devs will ramp up much faster, and experienced developers will learn some great stuff too!”—John Sandall on LinkedIn“It's gold - enjoying the book a lot! Gold nuggets everywhere.”—Ad Timmering on Twitter“Wow, that was quite a reading! If you are scared by typical complexity of technical books, don't be — this book is very approachable. Actually, I'd particularly recommend Boost Your Django DX to the folks who are just getting into the exciting world of Django because it explains how many goodies work and will help you not only write a better code, but do it faster, as well as understand where some of the potential pitfalls may appear. For me personally, the author's experience/background also plays a huge role and creates trust when I decide whether to spend time on a book. If you feel the same, do your homework or at least take a sneak peek here: https://forum.djangoproject.com/u/adamchainz”—Evgeni Sautin on Goodreads“Looking through the Boost Your Django DX table of contents. A lot of good stuff in there...Before I know it, I'm already on page 58, with some ideas for new approaches and productivity boosts. Great read! 🐍”—Katherine Michel on Twitter“I start reading the "Boost Your Django DX" book by @AdamChainz today. Its BRILLIANT ! 🤩 ”—Simon Krull on Twitter“I got a chance to be a beta reader of this book and can highly recommend it - a lot of great tips!”—Mateusz Bełczowski on Twitter“Finished reading @AdamChainz's "Boost Your #Django DX" book, lot of helpful advice and tips, recommended!”—Bob Belderbos on Twitter“It helps sometimes to see the same information presented in a new way and that's why I recommend the book for anyone working with Django”—Ryan on Twitter“Picked up @AdamChainz new book "Boost your Django DX" this weekend. Been using Django since pre-1.0 and like everything there's always something to learn.”—Kevin Fricovsky on Twitter

Gumroad
yamlfmt/docs/pre-commit.md at main · google/yamlfmt

An extensible command line tool or library to format yaml files. - google/yamlfmt

GitHub