Repository: pypa/twine

Issue:
twine 6 seems to break `twine check` "globs"
### Is there an existing issue for this?

- [X] I have searched the existing issues (open and closed), and could not find an existing issue

### What keywords did you use to search existing issues?

`glob`
`dist*`

### What operating system are you using?

macOS

### If you selected 'Other', describe your Operating System here

-

### What version of Python are you running?

```console
3.12.7
```


### How did you install twine? Did you use your operating system's package manager or pip or something else?

```console
`pip install twine`, but also `uv run` (see below)
```


### What version of twine do you have installed (include the complete output)

```console
twine version 6.0.0 (keyring: 25.5.0, pkginfo: 1.11.2, requests: 2.32.3, requests-toolbelt: 1.0.0, urllib3: 2.2.3)
```


### Which package repository are you using?

pypi production

### Please describe the issue that you are experiencing

`twine check "dist/*"` used to check all distributions in `dist`.
It's documented as the "way" to use twine check in its `--help`:

```
⊙  twine check --help                                                                                                                                                                                                                                                                                                                                             julian@Mac
usage: twine check [-h] [--strict] dist [dist ...]

positional arguments:
  dist        The distribution files to check, usually dist/*
```

But `twine 6` seems to no longer support this. (Here I've cloned the twine repository itself as a test package, and  run `pyproject-build .` on it to produce a `dist` directory).

```
⊙  uv run --with 'twine>=6' twine check 'dist/*'                                                                                                                                                                                                                                                                                                                  julian@Mac
Checking dist/*: ERROR    InvalidDistribution: Unknown distribution format: '*' 
```



### Please list the steps required to reproduce this behaviour

Previous versions still work fine of course:

```
⊙  uv run --with 'twine<6' twine check 'dist/*'                                                                                                                                                                                                                                                                                                                   julian@Mac
Installed 23 packages in 21ms
Checking dist/twine-6.0.1.dev5+g067412e-py3-none-any.whl: PASSED
Checking dist/twine-6.0.1.dev5+g067412e.tar.gz: PASSED

```

### Anything else you'd like to mention?

_No response_


Discussion:
Thanks for the report @Julian -- my SWAG is that this is a regression from https://github.com/pypa/twine/pull/1172. I'm looking at it now.
Oh, I think I see what's happening here -- `'dist/*'` means that the shell's own globbing isn't used, and the `_split_inputs` helper isn't handling globs on its own.
#1188 should fix this -- sorry for the breakage @Julian! 

Hooray! Thanks for the fast fix!
Not to press of course, but is the hope to do a 6.0.1 release of twine with this? It essentially breaks CI in all my projects unfortunately (for me), so just checking if I should put any effort into reworking my setups. (Though I guess I will anyhow for pinning twine's own version...)
I can prep a PR for a 6.0.1 release; I need to add a CHANGELOG entry anyways. 
I've opened #1189 with the release prep.
Amazing, let me know if I can help at all obviously.



Patch:
diff --git a/twine/commands/check.py b/twine/commands/check.py
index 6b0fe5c7..9637651e 100644
--- a/twine/commands/check.py
+++ b/twine/commands/check.py
@@ -127,6 +127,7 @@ def check(
     :return:
         ``True`` if there are rendering errors, otherwise ``False``.
     """
+    dists = commands._find_dists(dists)
     uploads, _, _ = commands._split_inputs(dists)
     if not uploads:  # Return early, if there are no files to check.
         logger.error("No files to check.")


Test patch:
diff --git a/tests/helpers.py b/tests/helpers.py
index df1a0cb8..c0b9da8c 100644
--- a/tests/helpers.py
+++ b/tests/helpers.py
@@ -18,10 +18,11 @@
 import pathlib
 
 TESTS_DIR = pathlib.Path(__file__).parent
-SDIST_FIXTURE = os.path.join(TESTS_DIR, "fixtures/twine-1.5.0.tar.gz")
-WHEEL_FIXTURE = os.path.join(TESTS_DIR, "fixtures/twine-1.5.0-py2.py3-none-any.whl")
-NEW_SDIST_FIXTURE = os.path.join(TESTS_DIR, "fixtures/twine-1.6.5.tar.gz")
-NEW_WHEEL_FIXTURE = os.path.join(TESTS_DIR, "fixtures/twine-1.6.5-py2.py3-none-any.whl")
+FIXTURES_DIR = os.path.join(TESTS_DIR, "fixtures")
+SDIST_FIXTURE = os.path.join(FIXTURES_DIR, "twine-1.5.0.tar.gz")
+WHEEL_FIXTURE = os.path.join(FIXTURES_DIR, "twine-1.5.0-py2.py3-none-any.whl")
+NEW_SDIST_FIXTURE = os.path.join(FIXTURES_DIR, "twine-1.6.5.tar.gz")
+NEW_WHEEL_FIXTURE = os.path.join(FIXTURES_DIR, "twine-1.6.5-py2.py3-none-any.whl")
 
 
 @contextlib.contextmanager
diff --git a/tests/test_check.py b/tests/test_check.py
index 2cf1d0be..ca62d2c1 100644
--- a/tests/test_check.py
+++ b/tests/test_check.py
@@ -18,6 +18,7 @@
 import pretend
 import pytest
 
+from tests import helpers
 from twine.commands import check
 
 
@@ -283,6 +284,21 @@ def test_main(monkeypatch):
     assert check_stub.calls == [pretend.call(["dist/*"], strict=False)]
 
 
+def test_check_expands_glob(monkeypatch):
+    """Regression test for #1187."""
+    warning_stream = pretend.stub()
+    warning_stream_cls = pretend.call_recorder(lambda: warning_stream)
+    monkeypatch.setattr(check, "_WarningStream", warning_stream_cls)
+
+    check_file = pretend.call_recorder(lambda fn, stream: ([], True))
+    monkeypatch.setattr(check, "_check_file", check_file)
+
+    assert not check.main([f"{helpers.FIXTURES_DIR}/*"])
+
+    # check_file is called more than once, indicating the glob has been expanded
+    assert len(check_file.calls) > 1
+
+
 # TODO: Test print() color output
 
 # TODO: Test log formatting