audreyfeldroy / cookiecutter-pypackage

Cookiecutter template for a Python package.
BSD 3-Clause "New" or "Revised" License
4.23k stars 1.78k forks source link

Error message: 'collections.OrderedDict object' has no attribute 'use_black' #737

Closed AI-Guru closed 5 months ago

AI-Guru commented 6 months ago

Description

I wanted to create a python package with cookiecutter. I filled in all the blanks in the interview on startup. Then I got an error. Then I tried again, this time only using the default values. Still the same error.

What I Did

cookiecutter https://github.com/audreyfeldroy/cookiecutter-pypackage.git

Here is the error message:

Unable to create file 'Makefile'
Error message: 'collections.OrderedDict object' has no attribute 'use_black'

Here is the output including the error message:

cookiecutter https://github.com/audreyfeldroy/cookiecutter-pypackage.git
You've downloaded /Users/tristanbehrens/.cookiecutters/cookiecutter-pypackage before. Is it okay to
delete and re-download it? [y/n] (y):

  [1/14] full_name (Audrey Roy Greenfeld):   [2/14] email (audreyr@example.com):
  [3/14] github_username (audreyr):
  [4/14] project_name (Python Boilerplate):
  [5/14] project_slug (python_boilerplate):
  [6/14] project_short_description (Python Boilerplate contains all the boilerplate you need to
create a Python package.):
  [7/14] pypi_username (audreyr):
  [8/14] version (0.1.0):
  [9/14] use_pytest (n):
  [10/14] use_pypi_deployment_with_travis (y):
  [11/14] add_pyup_badge (n):
  [12/14] Select command_line_interface
    1 - Typer
    2 - Argparse
    3 - No command-line interface
    Choose from [1/2/3] (1):
  [13/14] create_author_file (y):
  [14/14] Select open_source_license
    1 - MIT license
    2 - BSD license
    3 - ISC license
    4 - Apache Software License 2.0
    5 - GNU General Public License v3
    6 - Not open source
    Choose from [1/2/3/4/5/6] (1):
Unable to create file 'Makefile'
Error message: 'collections.OrderedDict object' has no attribute 'use_black'
Context: {
    "_cookiecutter": {
        "add_pyup_badge": "n",
        "command_line_interface": [
            "Typer",
            "Argparse",
            "No command-line interface"
        ],
        "create_author_file": "y",
        "email": "audreyr@example.com",
        "full_name": "Audrey Roy Greenfeld",
        "github_username": "audreyr",
        "open_source_license": [
            "MIT license",
            "BSD license",
            "ISC license",
            "Apache Software License 2.0",
            "GNU General Public License v3",
            "Not open source"
        ],
        "project_name": "Python Boilerplate",
        "project_short_description": "Python Boilerplate contains all the boilerplate you need to create a Python package.",
        "project_slug": "{{ cookiecutter.project_name.lower().replace(' ', '_').replace('-', '_') }}",
        "pypi_username": "{{ cookiecutter.github_username }}",
        "use_pypi_deployment_with_travis": "y",
        "use_pytest": "n",
        "version": "0.1.0"
    },
    "cookiecutter": {
        "__gh_slug": "audreyr/python_boilerplate",
        "_checkout": null,
        "_output_dir": "/Users/tristanbehrens/Development/CurrentProjects",
        "_repo_dir": "/Users/tristanbehrens/.cookiecutters/cookiecutter-pypackage",
        "_template": "https://github.com/audreyfeldroy/cookiecutter-pypackage.git",
        "add_pyup_badge": "n",
        "command_line_interface": "Typer",
        "create_author_file": "y",
        "email": "audreyr@example.com",
        "full_name": "Audrey Roy Greenfeld",
        "github_username": "audreyr",
        "open_source_license": "MIT license",
        "project_name": "Python Boilerplate",
        "project_short_description": "Python Boilerplate contains all the boilerplate you need to create a Python package.",
        "project_slug": "python_boilerplate",
        "pypi_username": "audreyr",
        "use_pypi_deployment_with_travis": "y",
        "use_pytest": "n",
        "version": "0.1.0"
    }
}
Flarenzy commented 6 months ago

I am getting the same error when running it with pipx run cookiecutter gh:audreyfeldroy/cookiecutter-pypackage On windows 10.

zodiaq commented 5 months ago

I had the same issue on my WSL2 env and found a solution. Patch ~/.cookiecutters/cookiecutter-pypackage/cookiecutter.json

--- cookiecutter.json   2024-04-09 23:00:55.324901260 +0900
+++ cookiecutter.json.new       2024-04-09 23:01:39.037179065 +0900
@@ -13,5 +13,6 @@
   "command_line_interface": ["Typer", "Argparse", "No command-line interface"],
   "create_author_file": "y",
   "open_source_license": ["MIT license", "BSD license", "ISC license", "Apache Software License 2.0", "GNU General Public License v3", "Not open source"],
-  "__gh_slug": "{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}"
+  "__gh_slug": "{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}",
+  "use_black": "n"
 }