pysal / momepy

Urban Morphology Measuring Toolkit
https://docs.momepy.org
BSD 3-Clause "New" or "Revised" License
496 stars 59 forks source link

Need for `contextlib` here? #492

Closed jGaboardi closed 1 year ago

jGaboardi commented 1 year ago

https://github.com/pysal/momepy/blob/130ddfde765820396c4b5f256f663aa13e32fda6/momepy/__init__.py#L20

Hey, @martinfleis! What's the actual need for with contextlib.suppress(PackageNotFoundError) here? I have been digging around but haven't found a clear answer.

martinfleis commented 1 year ago

If the package is not installed and you try to load __version__, it errors. You can either catch that with try/except as is in the setuptools_scm docs or like this, which is what ruff suggests instead.

jGaboardi commented 1 year ago

Got it! Another +1 Karma Point for you!

martinfleis commented 1 year ago

Here https://github.com/pypa/setuptools_scm#retrieving-package-version-at-runtime