internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: codespell-project/codespell

Issue:
Makefile is broken
The makefile is no longer working, since there is no longer a codespell.py



Discussion:
Can you submit a PR to fix it? Some entries could probably be removed and
others updated.

Actually most of the Makefile seems obsolete, it should probably be dropped to the profit of setuptools, or rewritten.

I agree. Something that does not work should be removed.

In order for setuptools to work correctly, `bin/codespell.py` should be renamed to `bin/codespell`, since its an executable.

setuptools seems to handle it okay even with the extension. Is it not
working for you on latest master? It's better for backward compatibility
not to change the filename if possible.

> not to change the filename if possible

Prior the recent refactoring the name was `codespell`.

Looking back at the repo before the refactoring I see `codespell.py` in the repo:

https://github.com/lucasdemarchi/codespell/tree/4cb7fe36d34784fcb11600834e39c001bee72b2c

Did it get installed as `codespell` when doing the installation step?

The rename was done by Makefile rule https://github.com/lucasdemarchi/codespell/blob/4cb7fe36d34784fcb11600834e39c001bee72b2c/Makefile#L16

It does break current operating system packages, and would require lots of otherwise unnecessary patching. Please rename it.

This would actually preserve backward compat.

http://python-packaging.readthedocs.io/en/latest/command-line-scripts.html

This link also suggests that executable scripts should drop the file extension


Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -55,4 +55,4 @@
               op.join('data', 'dictionary.txt'),
               op.join('data', 'linux-kernel.exclude'),
           ]},
-          scripts=['bin/codespell.py'])
+          scripts=['bin/codespell'])


Test patch:
diff --git a/codespell_lib/tests/test_basic.py b/codespell_lib/tests/test_basic.py
--- a/codespell_lib/tests/test_basic.py
+++ b/codespell_lib/tests/test_basic.py
@@ -18,12 +18,12 @@
 def run_codespell(args=(), cwd=None):
     """Helper to run codespell"""
     return subprocess.Popen(
-        ['codespell.py'] + list(args), cwd=cwd,
+        ['codespell'] + list(args), cwd=cwd,
         stdout=subprocess.PIPE, stderr=subprocess.PIPE).wait()
 
 
 def test_command():
-    """Test running codespell.py"""
+    """Test running the codespell executable"""
     # With no arguments does "."
     with TemporaryDirectory() as d:
         assert_equal(run_codespell(cwd=d), 0)
Repository: codespell-project/codespell

Issue:
README: outdated license notice
README says:

> The Python script `codespell.py` is available with the following terms:

But currently `codespell.py` is just a thin wrapper over `codespell_lib`, with little to no creativity.
This sentence should probably read something like this:

> The Python code is available with the following terms:



Discussion:
PR welcome


Resolving patch:
diff --git a/codespell_lib/_codespell.py b/codespell_lib/_codespell.py
--- a/codespell_lib/_codespell.py
+++ b/codespell_lib/_codespell.py
@@ -510,7 +510,6 @@ def main(*args):
             parser.print_help()
             return 1
         build_dict(dictionary)
-        
     colors = TermColors()
     if not options.colors:
         colors.disable()


Test patch:
Repository: codespell-project/codespell

Issue:
Making the build reproducible 
Hi all,

There is an effort in Debian to ensure packages do build reproducible. Currently, codespell does fail in this regard, because it includes a [path in the help output](https://github.com/lucasdemarchi/codespell/blob/master/codespell_lib/_codespell.py#L223) (and therefore in the manpage). There is a proposed patch in Debian which just disables embedding the path in the output -- but before applying it, I wanted to ask people over here: what do you think?

Also, I'm much more in favor of getting this fixed here, upstream, instead of in Debian, downstream.

Thanks for your work,
cheers,
Georg


Discussion:
I'm fine with removing the actual path and saying that it's part of the package data instead
Great, should I send a patch for this?
Yes please

Resolving patch:
diff --git a/codespell_lib/_codespell.py b/codespell_lib/_codespell.py
--- a/codespell_lib/_codespell.py
+++ b/codespell_lib/_codespell.py
@@ -220,9 +220,8 @@ def parse_options(args):
                       action='append', metavar='FILE',
                       help='Custom dictionary file that contains spelling '
                            'corrections. If this flag is not specified or '
-                           'equals "-" then default dictionary "%s" is used. '
-                           'This option can be specified multiple times.' %
-                      default_dictionary)
+                           'equals "-" then the default dictionary is used. '
+                           'This option can be specified multiple times.')
     parser.add_option('-I', '--ignore-words',
                       action='append', metavar='FILE',
                       help='File that contains words which will be ignored '


Test patch:
Repository: codespell-project/codespell

Issue:
Pass specific words to -I flag as parameters instead of needing to use a file 
Thanks to @thdot per #100 we can now use `-I <file name>` to ignore certain words. Each word needs to be on a separate line in the file. That is great when there is a place to save a whitelist file to so codespell can read it. 

But say we were in a [Buildbot](https://github.com/buildbot/buildbot) environment, an automated testing framework, where we've setup codespell as a unit test... and so there isn't an easy possibility to save a whitelist file somewhere? Or another scenario, we're trying to quickly filter out a ginormous list of false positives from a codespell result, one needs to open their favorite editor and add each word on a separate line and link said file. It's not the most efficient. 

It would be then useful to then have the the ability to pass the whitelisted words sequentially ex. `codespell -I 'nto,ans,pres,ot,amin'` 
Thoughts?
 


Discussion:

Resolving patch:
diff --git a/codespell_lib/_codespell.py b/codespell_lib/_codespell.py
--- a/codespell_lib/_codespell.py
+++ b/codespell_lib/_codespell.py
@@ -228,6 +228,12 @@ def parse_options(args):
                            'by codespell. File must contain 1 word per line. '
                            'Words are case sensitive based on how they are '
                            'written in codespell_lib/data/dictionary.txt')
+    parser.add_option('-L', '--ignore-words-list',
+                      action='append', metavar='WORDS',
+                      help='Comma separated list of words to be ignored '
+                           'by codespell. Words are case sensitive based on '
+                           'how they are written in '
+                           'codespell_lib/data/dictionary.txt')
     parser.add_option('-r', '--regex',
                       action='store', type='string',
                       help='Regular expression which is used to find words. '
@@ -595,6 +601,11 @@ def main(*args):
             return 1
         build_ignore_words(ignore_words_file)
 
+    ignore_words_list = options.ignore_words_list or []
+    for comma_separated_words in ignore_words_list:
+        for word in comma_separated_words.split(','):
+            ignore_words.add(word.strip())
+
     dictionaries = options.dictionary or [default_dictionary]
     for dictionary in dictionaries:
         if dictionary == "-":


Test patch:
diff --git a/codespell_lib/tests/test_basic.py b/codespell_lib/tests/test_basic.py
--- a/codespell_lib/tests/test_basic.py
+++ b/codespell_lib/tests/test_basic.py
@@ -198,6 +198,14 @@ def test_ignore_dictionary(reload_codespell_lib):
         assert cs.main('-I', f.name, d) == 1
 
 
+def test_ignore_word_list(reload_codespell_lib):
+    """Test ignore word list functionality"""
+    with TemporaryDirectory() as d:
+        with open(op.join(d, 'bad.txt'), 'w') as f:
+            f.write('abandonned\nabondon\nabilty\n')
+        assert cs.main('-Labandonned,someword', '-Labilty', d) == 1
+
+
 def test_custom_regex(reload_codespell_lib):
     """Test custom word regex"""
     with TemporaryDirectory() as d:
Repository: codespell-project/codespell

Issue:
Disable 'BINARY file' warning by default
Currently codespell prints warning if it finds a binary file in the
tree. It is annoying as many projects contain .git/.svn/images/object/etc files.
Disable the warning by default and let users enable it if needed.


Discussion:

Resolving patch:
diff --git a/codespell_lib/_codespell.py b/codespell_lib/_codespell.py
--- a/codespell_lib/_codespell.py
+++ b/codespell_lib/_codespell.py
@@ -281,15 +281,20 @@ def parse_options(args):
                              'is available. 3: both 1 and 2')
 
     parser.add_argument('-q', '--quiet-level',
-                        action='store', type=int, default=0,
-                        help='Bitmask that allows codespell to run quietly. '
-                             '0: the default, in which all messages are '
-                             'printed. 1: disable warnings about wrong '
-                             'encoding. 2: disable warnings about binary '
-                             'file. 4: shut down warnings about automatic '
-                             'fixes that were disabled in dictionary. '
+                        action='store', type=int, default=2,
+                        help='Bitmask that allows suppressing messages. '
+                             '0: print all messages. '
+                             '1: disable warnings about wrong encoding. '
+                             '2: disable warnings about binary files. '
+                             '4: omit warnings about automatic fixes that '
+                             'were disabled in the dictionary. '
                              '8: don\'t print anything for non-automatic '
-                             'fixes. 16: don\'t print fixed files.')
+                             'fixes. '
+                             '16: don\'t print the list of fixed files. '
+                             'As usual with bitmasks, these levels can be '
+                             'combined; e.g. use 3 for levels 1+2, 7 for '
+                             '1+2+4, 23 for 1+2+4+16, etc. '
+                             'The default mask is %(default)s.')
 
     parser.add_argument('-e', '--hard-encoding-detection',
                         action='store_true', default=False,


Test patch:
diff --git a/codespell_lib/tests/test_basic.py b/codespell_lib/tests/test_basic.py
--- a/codespell_lib/tests/test_basic.py
+++ b/codespell_lib/tests/test_basic.py
@@ -242,8 +242,9 @@ def test_encoding(tmpdir, capsys):
             f.write(b'\x00\x00naiive\x00\x00')
         capsys.readouterr()
         assert cs.main(f.name) == 0
+        assert capsys.readouterr() == ('', '')
+        assert cs.main('-q', '0', f.name) == 0
         assert 'WARNING: Binary file' in capsys.readouterr()[1]
-        assert cs.main('-q', '2', f.name) == 0
         assert capsys.readouterr() == ('', '')
     finally:
         os.remove(f.name)
Repository: codespell-project/codespell

Issue:
dictionary_rare missing
`codespell_lib/data/dictionary_rare.txt` is missing in the 1.17.0 PyPI source package causing a crash when all builtin dictionaries are used.


Discussion:

Resolving patch:
diff --git a/codespell_lib/_codespell.py b/codespell_lib/_codespell.py
--- a/codespell_lib/_codespell.py
+++ b/codespell_lib/_codespell.py
@@ -31,7 +31,7 @@
 USAGE = """
 \t%prog [OPTIONS] [file1 file2 ... fileN]
 """
-VERSION = '1.17.0'
+VERSION = '1.17.1'
 
 # Users might want to link this file into /usr/local/bin, so we resolve the
 # symbolic link path to the real path if necessary.


Test patch:
Repository: codespell-project/codespell

Issue:
Inconsistent handling of hidden files
If codespell is run on a directory, the contents of hidden files are checked:
```
$ codespell --version
1.18.dev0
$ codespell ./foo
./foo/.bar:1: abandonned ==> abandoned
```
but if codespell is pointed directly at a hidden file, it's ignored unless the `--check-hidden` option is used:
```
$ codespell ./foo/.bar
$ codespell --check-hidden ./foo/.bar
./foo/.bar:1: abandonned ==> abandoned
```
I would expect that if codespell is used without the `--check-hidden` option it should always ignore hidden files.
Inconsistent handling of hidden files
If codespell is run on a directory, the contents of hidden files are checked:
```
$ codespell --version
1.18.dev0
$ codespell ./foo
./foo/.bar:1: abandonned ==> abandoned
```
but if codespell is pointed directly at a hidden file, it's ignored unless the `--check-hidden` option is used:
```
$ codespell ./foo/.bar
$ codespell --check-hidden ./foo/.bar
./foo/.bar:1: abandonned ==> abandoned
```
I would expect that if codespell is used without the `--check-hidden` option it should always ignore hidden files.


Discussion:

Resolving patch:
diff --git a/codespell_lib/_codespell.py b/codespell_lib/_codespell.py
--- a/codespell_lib/_codespell.py
+++ b/codespell_lib/_codespell.py
@@ -714,6 +714,9 @@ def main(*args):
                     del dirs[:]
                     continue
                 for file_ in files:
+                    # ignore hidden files in directories
+                    if is_hidden(file_, options.check_hidden):
+                        continue
                     if glob_match.match(file_):  # skip files
                         continue
                     fname = os.path.join(root, file_)


Test patch:
diff --git a/codespell_lib/tests/test_basic.py b/codespell_lib/tests/test_basic.py
--- a/codespell_lib/tests/test_basic.py
+++ b/codespell_lib/tests/test_basic.py
@@ -279,18 +279,26 @@ def test_check_filename(tmpdir):
 def test_check_hidden(tmpdir):
     """Test ignoring of hidden files."""
     d = str(tmpdir)
-    # hidden file
+    # visible file
     with open(op.join(d, 'test.txt'), 'w') as f:
         f.write('abandonned\n')
     assert cs.main(op.join(d, 'test.txt')) == 1
+    assert cs.main(d) == 1
+    # hidden file
     os.rename(op.join(d, 'test.txt'), op.join(d, '.test.txt'))
     assert cs.main(op.join(d, '.test.txt')) == 0
+    assert cs.main(d) == 0
     assert cs.main('--check-hidden', op.join(d, '.test.txt')) == 1
+    assert cs.main('--check-hidden', d) == 1
+    # hidden file with typo in name
     os.rename(op.join(d, '.test.txt'), op.join(d, '.abandonned.txt'))
     assert cs.main(op.join(d, '.abandonned.txt')) == 0
+    assert cs.main(d) == 0
     assert cs.main('--check-hidden', op.join(d, '.abandonned.txt')) == 1
+    assert cs.main('--check-hidden', d) == 1
     assert cs.main('--check-hidden', '--check-filenames',
                    op.join(d, '.abandonned.txt')) == 2
+    assert cs.main('--check-hidden', '--check-filenames', d) == 2
 
 
 def test_case_handling(tmpdir, capsys):
Repository: codespell-project/codespell

Issue:
Make a release
There have been many commits and much work done since the last release, v1.17.1 on May 22 - 5 month ago.

Can you please make a new release so we can all benefit from the great work done over the past 5 months?


Discussion:
Personally I think it would be good to get #1669 in at least and I think there are a few others, but yes I'd agree in principal.

I think there were a few other little bits to get in, but they could perhaps wait.
@peternewman let me know when you're happy and I can cut a new release
Hi folks. Just wondering if there has been any progress on this since last month? I'm very appreciative of the work that's been done here, and would love to use some of the new features like the `--config` support!

Fwiw I was a bit confused after seeing this in the README but found it not to be available in the latest release. I'm not familiar with your release process, but perhaps it would be less confusing to new users if unreleased changes were not published to the README until they are available?
Hey,

the Readme is up to date with the master branch. If you install the version of the master branch [1], you get the feature. The only option would be to have a develop branch and 
only push releases to master. But this would confuse other people.

[1] pip3 install git+https://github.com/codespell-project/codespell.git

Resolving patch:
diff --git a/codespell_lib/_codespell.py b/codespell_lib/_codespell.py
--- a/codespell_lib/_codespell.py
+++ b/codespell_lib/_codespell.py
@@ -33,7 +33,7 @@
 USAGE = """
 \t%prog [OPTIONS] [file1 file2 ... fileN]
 """
-VERSION = '2.0.dev0'
+VERSION = '2.0.0'
 
 supported_languages_en = ('en', 'en_GB', 'en_US', 'en_CA', 'en_AU')
 supported_languages = supported_languages_en


Test patch:
Repository: codespell-project/codespell

Issue:
codespell fails with uncaught exception on unreadable files
```sh
$ mkdir -p foo/bar
$ touch foo/bar/file
$ chmod a= foo/bar/file
$ cd foo
$ 
$ codespell 
Traceback (most recent call last):
  File "/home/username/.local/bin/codespell", line 11, in <module>
    load_entry_point('codespell', 'console_scripts', 'codespell')()
  File "/my/path/codespell/codespell_lib/_codespell.py", line 746, in _script_main
    return main(*sys.argv[1:])
  File "/my/path/codespell/codespell_lib/_codespell.py", line 897, in main
    bad_count += parse_file(
  File "/my/path/codespell/codespell_lib/_codespell.py", line 630, in parse_file
    text = is_text_file(filename)
  File "/my/path/codespell/codespell_lib/_codespell.py", line 488, in is_text_file
    with open(filename, mode='rb') as f:
PermissionError: [Errno 13] Permission denied: './bar/file'
$ 
```


Discussion:
Nice find, another warning to add like the missing files.
It could fail silently (as it does on files deleted after `os.walk()`) or emit a warning. In this case, I agree with you: we require a warning.

Resolving patch:
diff --git a/codespell_lib/_codespell.py b/codespell_lib/_codespell.py
--- a/codespell_lib/_codespell.py
+++ b/codespell_lib/_codespell.py
@@ -647,14 +647,22 @@ def parse_file(filename, colors, summary, misspellings, exclude_lines,
         if not os.path.isfile(filename):
             return bad_count
 
-        text = is_text_file(filename)
+        try:
+            text = is_text_file(filename)
+        except PermissionError as e:
+            print("WARNING: %s: %s" % (e.strerror, filename),
+                  file=sys.stderr)
+            return bad_count
+        except OSError:
+            return bad_count
+
         if not text:
             if not options.quiet_level & QuietLevels.BINARY_FILE:
                 print("WARNING: Binary file: %s" % filename, file=sys.stderr)
             return bad_count
         try:
             lines, encoding = file_opener.open(filename)
-        except Exception:
+        except OSError:
             return bad_count
 
     for i, line in enumerate(lines):


Test patch:
diff --git a/codespell_lib/tests/test_basic.py b/codespell_lib/tests/test_basic.py
--- a/codespell_lib/tests/test_basic.py
+++ b/codespell_lib/tests/test_basic.py
@@ -122,6 +122,20 @@ def test_basic(tmpdir, capsys):
     assert cs.main(d) == 0
 
 
+@pytest.mark.skipif(
+    not sys.platform == 'linux', reason='Only supported on Linux')
+def test_permission_error(tmp_path, capsys):
+    """Test permission error handling."""
+    d = tmp_path
+    with open(d / 'unreadable.txt', 'w') as f:
+        f.write('abandonned\n')
+    code, _, stderr = cs.main(f.name, std=True)
+    assert 'WARNING:' not in stderr
+    os.chmod(f.name, 0o000)
+    code, _, stderr = cs.main(f.name, std=True)
+    assert 'WARNING:' in stderr
+
+
 def test_interactivity(tmpdir, capsys):
     """Test interaction"""
     # Windows can't read a currently-opened file, so here we use
Repository: codespell-project/codespell

Issue:
[Build] QA warning about codespell_lib.tests being installed as data
While packaging v2.2.0 for Gentoo Linux, I got a QA notice about this:

```
* QA Notice: setuptools warnings detected:
 * 
 *          Installing 'codespell_lib.tests' as data is deprecated, please list it in `packages`.
```

The actual setuptools warning is as (here shown for Python 3.11, but same for 3.10)

```
/usr/lib/python3.11/site-packages/setuptools/command/build_py.py:202: SetuptoolsDeprecationWarning:     Instal
ling 'codespell_lib.tests' as data is deprecated, please list it in `packages`.
    !!


    ############################
    # Package would be ignored #
    ############################
    Python recognizes 'codespell_lib.tests' as an importable package,
    but it is not listed in the `packages` configuration of setuptools.

    'codespell_lib.tests' has been automatically added to the distribution only
    because it may contain data files, but this behavior is likely to change
    in future versions of setuptools (and therefore is considered deprecated).

    Please make sure that 'codespell_lib.tests' is included as a package by using
    the `packages` configuration field or the proper discovery methods
    (for example by using `find_namespace_packages(...)`/`find_namespace:`
    instead of `find_packages(...)`/`find:`).

    You can read more about "package discovery" and "data files" on setuptools
    documentation page.


!!

  check.warn(importable)
```

Find attached the full build log.
[codespell-2.2.0:20220818-083735.log](https://github.com/codespell-project/codespell/files/9371941/codespell-2.2.0.20220818-083735.log)



Discussion:
Thanks for reporting @waebbl  
CC @larsoner if you have a moment, do you mind looking in to this? 

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -46,15 +46,13 @@
           python_requires='>=3.6',
           packages=[
               'codespell_lib',
+              'codespell_lib.tests',
               'codespell_lib.data',
           ],
           package_data={'codespell_lib': [
               os.path.join('data', 'dictionary*.txt'),
               os.path.join('data', 'linux-kernel.exclude'),
           ]},
-          exclude_package_data={'codespell_lib': [
-              os.path.join('tests', '*'),
-          ]},
           entry_points={
               'console_scripts': [
                   'codespell = codespell_lib:_script_main'


Test patch: