0

I have a local package B which depends on another local package A. They both are stored in a company repository: https://mycompany.com/api/pypi/pypi-bld/simple. Therefore, tests of B requires A.

I need to use pre-commit which uses both the company repository and the default one. I use this .pre-commit-config.yaml, where I have black, pre-commit-hooks, flake8 and init tests:

repos:
  - repo: https://github.com/psf/black
    some parameters...
  - repo: https://github.com/pre-commit/pre-commit-hooks
    some parameters...
  - repo: https://github.com/pycqa/flake8
    some parameters...
  - repo: local
    hooks:
      - id: unittest
        name: unittest
        entry: python -m unittest discover
        language: python
        language_version: "3.9"
        "types": [python]
        pass_filenames: false
        stages: [commit]
        additional_dependencies: ['--index-url', 'https://<USERNAME>:<PASSWORD>@mycompany.com/api/pypi/pypi-bld/simple',
                                  'requests', 'mylocal-package']

As you can see there is credential information. It is dangerous. So, how to specify in a more clever way? Maybe it is possible to specify a custom pip from virtualenv for pre-commit?

Eugene W.
  • 357
  • 3
  • 11
  • Also, I found out that pre-commit intentionally does not read from the repository under test as this makes caching intractable `https://stackoverflow.com/questions/65940222/pre-commit-com-same-version-in-pre-commit-config-yaml-and-requirements-txt`. So it can be very hard to reach what I want – Eugene W. Mar 02 '23 at 18:06
  • 1
    running tests as part of pre-commit is a bad idea -- it's too slow (pre-commit should be for very fast checks only). otherwise your contributors will get frustrated and turn the whole thing off – anthony sottile Mar 02 '23 at 18:08
  • for me, it was ok, before splitting a big package into `A` and `B`. pre-commit took less than a minute. It is ok, in comparison with the time of code development. – Eugene W. Mar 02 '23 at 18:11
  • 1
    alright glhf -- I'm not going to encourage a bad idea so you're on your own – anthony sottile Mar 02 '23 at 18:16
  • you didn't explain why it is a bad idea, of course, I have blake, flake8 etc, but I have hidden them. My unit tests are very fast and committing is rare, (1 or 2 times per day), I don't want to refuse this idea due to the expenses of 10-20 sec per day:) – Eugene W. Mar 03 '23 at 07:33
  • I 100% did explain you just chose to ignore it – anthony sottile Mar 03 '23 at 13:46
  • the answer that it is not possible can satisfy me. – Eugene W. Mar 05 '23 at 14:05

0 Answers0