### Summary

While specifying requirements.yml to install roles like - 

```
ansible-galaxy role install -r requirements.yml -vvvv
```

With `requirements.yml` (I understand this file syntax is wrong)

```yaml
---
community.vmware
```

results in 
```
ERROR! Unexpected Exception, this is probably a bug: 'str' object has no attribute 'keys'
the full traceback was:

Traceback (most recent call last):
  File "/Volumes/data/src/ansible/lib/ansible/cli/__init__.py", line 659, in cli_executor
    exit_code = cli.run()
                ^^^^^^^^^
  File "/Volumes/data/src/ansible/bin/ansible-galaxy", line 749, in run
    return context.CLIARGS['func']()
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Volumes/data/src/ansible/bin/ansible-galaxy", line 120, in method_wrapper
    return wrapped_method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Volumes/data/src/ansible/bin/ansible-galaxy", line 1368, in execute_install
    requirements = self._parse_requirements_file(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Volumes/data/src/ansible/bin/ansible-galaxy", line 840, in _parse_requirements_file
    extra_keys = set(file_requirements.keys()).difference(set(['roles', 'collections']))
                     ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'keys'
```

### Issue Type

Bug Report

### Component Name

ansible-galaxy

### Ansible Version

```console
$ ansible --version
ansible [core 2.17.0.dev0] (i81713 310625996d) last updated 2023/10/04 11:27:33 (GMT -400)
  config file = /Volumes/data/src/playbooks/ansible.cfg
  configured module search path = ['/Users/akasurde/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Volumes/data/src/ansible/lib/ansible
  ansible collection location = /Users/akasurde/.ansible/collections:/usr/share/ansible/collections
  executable location = /Volumes/data/src/ansible/bin/ansible
  python version = 3.11.3 (main, May 10 2023, 12:50:08) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/Users/akasurde/.pyenv/versions/3.11.3/bin/python)
  jinja version = 3.1.2
  libyaml = True
```


### Configuration

```console
# if using a version older than ansible-core 2.12 you should omit the '-t all'
$ ansible-config dump --only-changed -t all
```


### OS / Environment

Red Hat Enterprise Linux release 8.2 (Ootpa)

### Steps to Reproduce

Trying installing role/collection with the above requirements.yml file.


### Expected Results

Installation successful.

### Actual Results

```console
ERROR! Unexpected Exception, this is probably a bug: 'str' object has no attribute 'keys'
the full traceback was:

Traceback (most recent call last):
  File "/Volumes/data/src/ansible/lib/ansible/cli/__init__.py", line 659, in cli_executor
    exit_code = cli.run()
                ^^^^^^^^^
  File "/Volumes/data/src/ansible/bin/ansible-galaxy", line 749, in run
    return context.CLIARGS['func']()
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Volumes/data/src/ansible/bin/ansible-galaxy", line 120, in method_wrapper
    return wrapped_method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Volumes/data/src/ansible/bin/ansible-galaxy", line 1368, in execute_install
    requirements = self._parse_requirements_file(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Volumes/data/src/ansible/bin/ansible-galaxy", line 840, in _parse_requirements_file
    extra_keys = set(file_requirements.keys()).difference(set(['roles', 'collections']))
                     ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'keys'
```


### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct
install_path = to_text(tmp_path_factory.mktemp('test-ÅÑŚÌβŁÈ Collections'))
    # FIXME: we should add the collection name in the error message
    # Used to be: expected = "Invalid collection name '%s', name must be in the format <namespace>.<collection>" % expected
    expected = "Neither the collection requirement entry key 'name', nor 'source' point to a concrete resolvable collection artifact. "
    expected += r"Also 'name' is not an FQCN\. A valid collection name must be in the format <namespace>\.<collection>\. "
    expected += r"Please make sure that the namespace and the collection name contain characters from \[a\-zA\-Z0\-9_\] only\."
    gc = GalaxyCLI(args=['ansible-galaxy', 'collection', 'install', name, '-p', os.path.join(install_path, 'install')])
    with pytest.raises(AnsibleError, match=expected):
        gc.run()
@pytest.mark.parametrize('collection_skeleton', [
    ('ansible_test.build_collection', None),
], indirect=True)
def test_collection_build(collection_artifact):
    tar_path = os.path.join(collection_artifact, 'ansible_test-build_collection-1.0.0.tar.gz')
    rt tarfile.is_tarfile(tar_path)
    with tarfile.open(tar_path, mode='r') as tar:
        tar_members = tar.getmembers()
        valid_files = ['MANIFEST.json', 'FILES.json', 'roles', 'docs', 'plugins', 'plugins/README.md', 'README.md',
                       'runme.sh', 'meta', 'meta/runtime.yml']
        rt len(tar_members) == len(valid_files)
        # Verify the uid and gid is 0 and the correct perms are set
        for member in tar_members:
            rt member.name in valid_files
            rt member.gid == 0
            rt member.gname == ''
            rt member.uid == 0
            rt member.uname == ''
            if member.isdir() or member.name == 'runme.sh':
                rt member.mode == 0o0755
            else: