1

In my .pre-commit-config.yaml, I have the following config for mypy:

  - repo: https://github.com/pre-commit/mirrors-mypy
    rev: v0.971
    hooks:
      - id: mypy
        args: [--strict]
        additional_dependencies:
          [
            apache-airflow==2.3.3,
            apache-airflow-providers-apache-hive==4.0.0,
            apache-airflow-providers-apache-livy==3.1.0,
            types-protobuf==3.20.4,
          ]

This works ok if all these dependencies come from the public pypi index. What should I do if I have a package comes from a custom pypi index? How can I update my config in this case? Thanks.

anthony sottile
  • 61,815
  • 15
  • 148
  • 207
WZH
  • 354
  • 2
  • 12

1 Answers1

6

if you need custom packages you'll utilize the same --index-url argument you'd send to pip in additional_dependencies:

        additional_dependencies:
          [
            '--index-url=https://example.com/simple',
            apache-airflow==2.3.3,
            apache-airflow-providers-apache-hive==4.0.0,
            apache-airflow-providers-apache-livy==3.1.0,
            types-protobuf==3.20.4,
          ]

disclaimer: I wrote pre-commit

anthony sottile
  • 61,815
  • 15
  • 148
  • 207
  • Thanks Anthony! What if some packages come from Pypi while others come from my private pypi index? At the moment, my private pypi doesn't contain all public indexes. – WZH Oct 26 '22 at 18:25
  • 1
    it's not different than pip, so `--extra-index-url=...` -- though **note that extra-index-url is a security problem as someone could namesnipe your internal packages** so you probably don't want to do that – anthony sottile Oct 26 '22 at 21:37