Search code examples
python-3.xmypypre-commit-hookpre-commitpre-commit.com

pre-commit mypy with additional_dependencies from custom Pypi index


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.


Solution

  • 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