123 Commits

Author SHA1 Message Date
Issy Long
975a707b3c
Bump some utils/ files to Sorbet typed: strict 2025-01-22 22:01:34 +00:00
Sam Ford
cf22382921
Curl: use typed: strict
This upgrades `utils/curl.rb` to `typed: strict`, which requires
a number of changes to pass `brew typecheck`. The most
straightforward are adding type signatures to methods, adding type
annotations (e.g., `T.let`) to variables that need them, and ensuring
that methods always use the expected return type.

I had to refactor areas where we call a `Utils::Curl` method and use
array destructuring on a `SystemCommand::Result` return value
(e.g., `output, errors, status = curl_output(...)`), as Sorbet
doesn't understand implicit array conversion. As suggested by Markus,
I've switched these areas to use `#stdout`, `#stderr`, and `#status`.
This requires the use of an intermediate variable (`result`) in some
cases but this was a fairly straightforward substitution.

I also had to refactor how `Cask::URL::BlockDSL::PageWithURL` works.
It currently uses `page.extend PageWithURL` to add a `url` attribute
but this reworks it to subclass `SimpleDelegator` and use an
`initialize` method instead. This achieves the same goal but in a way
that Sorbet can understand.
2025-01-14 08:14:39 -05:00
Patrick Linnane
d04430d1a5
brew style --fix
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2024-11-26 14:09:13 -08:00
Douglas Eichelberger
ffb15ffcf5
brew style --fix 2024-11-05 16:44:12 +00:00
Issy Long
45978435e7
rubocop: Use Sorbet/StrictSigil as it's better than comments
- Previously I thought that comments were fine to discourage people from
  wasting their time trying to bump things that used `undef` that Sorbet
  didn't support. But RuboCop is better at this since it'll complain if
  the comments are unnecessary.

- Suggested in https://github.com/Homebrew/brew/pull/18018#issuecomment-2283369501.

- I've gone for a mixture of `rubocop:disable` for the files that can't
  be `typed: strict` (use of undef, required before everything else, etc)
  and `rubocop:todo` for everything else that should be tried to make
  strictly typed. There's no functional difference between the two as
  `rubocop:todo` is `rubocop:disable` with a different name.

- And I entirely disabled the cop for the docs/ directory since
  `typed: strict` isn't going to gain us anything for some Markdown
  linting config files.

- This means that now it's easier to track what needs to be done rather
  than relying on checklists of files in our big Sorbet issue:

```shell
$ git grep 'typed: true # rubocop:todo Sorbet/StrictSigil' | wc -l
    268
```

- And this is confirmed working for new files:

```shell
$ git status
On branch use-rubocop-for-sorbet-strict-sigils
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        Library/Homebrew/bad.rb
        Library/Homebrew/good.rb

nothing added to commit but untracked files present (use "git add" to track)

$ brew style
Offenses:

bad.rb:1:1: C: Sorbet/StrictSigil: Sorbet sigil should be at least strict got true.
^^^^^^^^^^^^^

1340 files inspected, 1 offense detected
```
2024-08-12 15:24:27 +01:00
William Woodruff
79dabc918b
utils/pypi: add missing import
This was transitively imported before.

Signed-off-by: William Woodruff <william@yossarian.net>
2024-07-15 09:34:15 -04:00
William Woodruff
e8ce1841d5
pypi: source wheel -> universal wheel
Signed-off-by: William Woodruff <william@yossarian.net>
2024-07-14 12:51:41 -04:00
William Woodruff
547e33ccb7
pypi: allow source wheels as resources
Signed-off-by: William Woodruff <william@yossarian.net>
2024-07-14 11:58:36 -04:00
Markus Reiter
480e264d9a
Lint Ruby docs. 2024-05-01 11:35:21 +02:00
Markus Reiter
caf87c0336
Warn about undocumented non-private APIs. 2024-05-01 11:35:20 +02:00
Markus Reiter
0f0055ede4
Make documentation @api private by default. 2024-04-26 19:04:20 +02:00
Markus Reiter
c76170a456
Hide #to_s in docs. 2024-04-26 14:04:55 +02:00
Michael Cho
393a97f868
utils/pypi: allow overwriting resource patches
Signed-off-by: Michael Cho <michael@michaelcho.dev>
2024-03-16 13:55:19 -04:00
Mike McQuaid
ea2892f8ee
brew.rb: handle missing args. 2024-03-07 16:20:20 +00:00
Mike McQuaid
5a68dea2d6
Merge pull request #16771 from cho-m/pypi-package_name-version
utils/pypi: default to formula version when using package_name
2024-03-06 15:21:37 +00:00
Mike McQuaid
c3d18113c3
Merge pull request #16790 from cho-m/pypi-ignore-test-resources
utils/pypi: ignore test resources when counting matches
2024-03-04 14:41:18 +00:00
Michael Cho
7303d642dd
utils/pypi: specify dependencies needed to update resources
Also allow optionally installing these dependencies. By default, only
`python@3.y` formulae will be automatically installed.

Signed-off-by: Michael Cho <michael@michaelcho.dev>
2024-03-02 22:01:25 -05:00
Michael Cho
408c8e806f
utils/pypi: ignore test resources when counting matches
Signed-off-by: Michael Cho <michael@michaelcho.dev>
2024-03-01 16:26:34 -05:00
Michael Cho
79bbad9b38
utils/pypi: default to formula version when using package_name
Signed-off-by: Michael Cho <michael@michaelcho.dev>
2024-02-29 13:48:43 -05:00
Michael Cho
b59921d174
utils/pypi: improve style
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2024-02-27 13:32:52 -05:00
Michael Cho
31533cff05
utils/pypi: allow only updating extra_packages 2024-02-27 10:40:42 -05:00
Issy Long
f4218a6316
Fix RuboCop Performance/MapCompact offenses
- Rename an iterator variable since it would make the line too long.
2024-02-25 22:59:59 +00:00
Michael Cho
53bb72548a
utils/pypi: use python from formula for non-pypi url metadata
This fixes the resource detection when formula has Python packages that
are not compatible with current aliased python formula, e.g. `awscli`

Also switch to `opt_libexec` path to ignore Python formula patch version
and revision bump differences.
2024-02-22 09:42:41 -05:00
Sean Molenaar
f2eb1564e4
Update Library/Homebrew/utils/pypi.rb 2024-02-12 16:12:52 +01:00
Sean Molenaar
44206bb8f0
Update Library/Homebrew/utils/pypi.rb 2024-02-12 16:09:33 +01:00
Sean Molenaar
8c16ccc646
Update pypi.rb
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2024-02-12 15:39:51 +01:00
Sean Molenaar
e307c736a5 fix: fail if superfluous packages are excluded 2024-02-06 10:14:19 +01:00
Mike McQuaid
8486ff88f1
utils/pypi: readability tweak. 2024-01-09 08:50:08 +00:00
Branch Vincent
ecc60a13e0
pypi: stop excluding setuptools 2024-01-08 19:17:45 -08:00
Michael Cho
10659a1d61
update-python-resources: show pip install failure when --verbose
Also use `--disable-pip-version-check` to remove pip update notices
2023-12-30 12:16:09 -05:00
Michael Cho
326774faee
utils/pypi: use python from formula
Sometimes the Python dependency tree will be impacted by the exact
version of Python being used (most commonly relating to functionality
provided/missing from stdlibs like `importlib-metadata` and `tomllib`)
2023-12-19 20:09:09 -05:00
Mike McQuaid
b7114651ac
utils/curl: include or use explicitly.
Include or use `Utils::Curl` explicitly everywhere it is used.
2023-09-04 22:17:57 -04:00
Branch Vincent
47e82add43
utils/pypi: exclude deps of excluded packages 2023-08-21 21:45:54 -07:00
Branch Vincent
e5ed11a5b7
pypi: support updating resources for git clones 2023-08-05 17:12:23 -07:00
William Woodruff
81b768a978
utils/pypi: fix an incorrect return type
Signed-off-by: William Woodruff <william@yossarian.net>
2023-07-25 10:36:49 -04:00
Douglas Eichelberger
08e46c18cd Add type to Formula attrs 2023-07-24 14:12:36 -07:00
Dustin Rodrigues
b12f714a44
utils/pypi: don't overwrite name/extras/version from basic_metadata if already set 2023-07-17 21:50:26 -04:00
William Woodruff
da326d602d
pypi: improve error message
Emphasize that we're failing because the user tried to update
a non-PyPI package by version, when only PyPI packages can
be updated by version. Other Python packages need to be updated
by a full URL change.

Signed-off-by: William Woodruff <william@yossarian.net>
2023-07-02 21:54:27 -04:00
William Woodruff
0160bc53e4
brew style --fix
Signed-off-by: William Woodruff <william@yossarian.net>
2023-07-02 21:15:49 -04:00
William Woodruff
ed653ab219
pypi: handle ignore_non_pypi_packages correctly
Signed-off-by: William Woodruff <william@yossarian.net>
2023-07-02 21:08:54 -04:00
William Woodruff
91a9b57d1f
Revert "Revert "PyPI: Handle non-pythonhosted formula URLs""
This reverts commit 286e175a313bfc4505f972c343200dfa7e6afef5.
2023-07-02 20:46:46 -04:00
Mike McQuaid
286e175a31
Revert "PyPI: Handle non-pythonhosted formula URLs" 2023-06-05 17:21:56 +01:00
William Woodruff
0f40e224bd
utils/pypi: refactor instance variables
Signed-off-by: William Woodruff <william@yossarian.net>
2023-06-05 10:16:19 -04:00
William Woodruff
7067f72eb0
utils/pypi: fix sig
Signed-off-by: William Woodruff <william@yossarian.net>
2023-06-04 23:49:20 -04:00
William Woodruff
af6f728eb4
utils, test: rewrite PyPI::Package
This rewrites the `Package` class from the ground up
to better accomodate non-PyPI URLs.

The existing APIs are largely preserved, but with
clearer invariants around when they can or can't be used
(e.g., `#pypi_info`).

Signed-off-by: William Woodruff <william@yossarian.net>
2023-06-04 23:32:09 -04:00
William Woodruff
0b3a5d0f6c
utils/pypi: set default from_pypi
Signed-off-by: William Woodruff <william@yossarian.net>
2023-06-04 00:36:23 -04:00
William Woodruff
685693a8fe
utils/pypi: enforce non-pypi urls
Signed-off-by: William Woodruff <william@yossarian.net>
2023-06-04 00:27:34 -04:00
William Woodruff
f8d6dd4b94
utils/pypi: ensure Python
Signed-off-by: William Woodruff <william@yossarian.net>
2023-06-03 23:47:41 -04:00
William Woodruff
009ebff85c
utils/pypi: trim exception
Signed-off-by: William Woodruff <william@yossarian.net>
2023-06-03 23:17:59 -04:00
William Woodruff
d8b6bb2d4c
utils/pypi: more docs
Signed-off-by: William Woodruff <william@yossarian.net>
2023-06-03 23:15:44 -04:00