youtype / mypy_boto3_builder

Type annotations builder for boto3 compatible with VSCode, PyCharm, Emacs, Sublime Text, pyright and mypy.
https://youtype.github.io/mypy_boto3_builder/
MIT License
544 stars 36 forks source link

Adjust no-smart-version option to enable offline builds #225

Closed mbalatsko closed 1 year ago

mbalatsko commented 1 year ago

Notes

There are use cases, in which some might benefit from building stub packages from source, without making PyPI requests. Currently, any cli options combination allows you to achieve it.

This PR introduces a adjustment of no-smart-version option to serve these purpose

Type of change

Checklist

All of these are optional:

vemel commented 1 year ago

Thank you for your pull request.

Definitely, there should be a way to run builder in offline mode. I think --offline flag can be combined with --no-smart-version. Also, --skip-published flag can be ignored if --no-smart-version is provided.

So, we can use something like this:

    def _get_package_version(self, pypi_name: str, version: str) -> str | None:
        if self.disable_smart_version:
            return version

        pypi_manager = PyPIManager(pypi_name)
        if not pypi_manager.has_version(version):
            return version

        if self.skip_published:
            self.logger.info(f"Skipping {pypi_name} {version}, already on PyPI")
            return None

        return pypi_manager.get_next_version(version)

And CLI args help in cli_parser.py

What do you think?

vemel commented 1 year ago

GitHub reviews are down, unfortunately. I will leave a review ASAP.

mbalatsko commented 1 year ago

I like this idea, it makes great sense and does not complicate api. Let me make changes!

vemel commented 1 year ago

Awesome! Please update your PR once you have time.

vemel commented 1 year ago

LGTM! Thank you for your contribution