Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

474
Views
Ignorando las migraciones de Django en el archivo pyproject.toml para el formateador Black

Acabo de configurar Black y Pre-Commit para mi repositorio de Django.

Usé la configuración predeterminada para Black del tutorial que seguí y ha funcionado muy bien, pero tengo problemas para excluir mis archivos de migración.

Aquí está la configuración predeterminada que he estado usando:

pyproject.toml

 [tool.black] line-length = 79 include = '\.pyi?$' exclude = ''' /( \.git | \.hg | \.mypy_cache | \.tox | \.venv | _build | buck-out | build | dist )/ '''

Usé Regex101.com para asegurarme de que ^.*\b(migrations)\b.*$ coincidiera con apps/examples/migrations/test.py .

 [tool.black] line-length = 79 include = '\.pyi?$' exclude = ''' /( \.git | \.hg | \.mypy_cache | \.tox | \.venv | _build | buck-out | build | dist | ^.*\b(migrations)\b.*$ )/ '''

Cuando agrego esa línea regex a mi archivo de configuración y ejecuto pre-commit run --all-files , ignora la carpeta .git pero aún formatea los archivos de migraciones.

over 4 years ago · Santiago Trujillo
4 answers
Answer question

0

Prueba esto (observa la última línea):

 [tool.black] line-length = 79 include = '\.pyi?$' exclude = ''' /( \.git | \.hg | \.mypy_cache | \.tox | \.venv | _build | buck-out | build | dist | migrations )/ '''
over 4 years ago · Santiago Trujillo Report

0

Agregue la exclusión de migración a su .pre-commit-config.yaml

 - id: black exclude: ^.*\b(migrations)\b.*$
over 4 years ago · Santiago Trujillo Report

0

Esa es la solución al problema: pyproject.toml

 [tool.black] exclude = ''' /( | migrations )/ '''
over 4 years ago · Santiago Trujillo Report

0

Mantener dos lugares diferentes para la configuración de exclude no se ve bien si es evitable y tampoco funcionará bien para el CI (si desea realizar una ejecución en seco en negro en las comprobaciones de relaciones públicas). Agregar los siguientes trabajos para pyproject.toml y luego puede ejecutar lo mismo en el gancho de confirmación previa y CI:

 [tool.black] ... exclude = ''' ( /( ... | .+/migrations )/ ) '''
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!