pre-commit mypy with additional_dependencies from custom Pypi index
Asked Answered
U

1

5

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.

Unreasoning answered 23/10, 2022 at 13:2 Comment(0)
S
9

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

Sash answered 23/10, 2022 at 17:4 Comment(2)
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.Unreasoning
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 thatSash

© 2022 - 2024 — McMap. All rights reserved.