Skip to content

Fix check unused arguments false positive bug #8542

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 6, 2023

Conversation

Emplis
Copy link
Contributor

@Emplis Emplis commented Apr 5, 2023

Type of Changes

Type
🐛 Bug fix
✨ New feature
🔨 Refactoring
📜 Docs

Description

Problem: the special method __new__ must match the arguments of the __init__ method even if __new__ method does not use them. This generate unused-argument for the __new__ method.

Fix: the unused arguments check should not be done on the __new__ method if the __init__ method is defined in the same class.

Closes #3670

@Emplis Emplis force-pushed the fix-check-unused-args branch from 3411d52 to 64a5d0a Compare April 5, 2023 13:32
@codecov
Copy link

codecov bot commented Apr 5, 2023

Codecov Report

Merging #8542 (3417c49) into main (82cee37) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 3417c49 differs from pull request most recent head 66ee6a6. Consider uploading reports for the commit 66ee6a6 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #8542   +/-   ##
=======================================
  Coverage   95.90%   95.90%           
=======================================
  Files         174      174           
  Lines       18353    18361    +8     
=======================================
+ Hits        17602    17610    +8     
  Misses        751      751           
Impacted Files Coverage Δ
pylint/checkers/variables.py 97.17% <100.00%> (+0.01%) ⬆️

@github-actions
Copy link
Contributor

github-actions bot commented Apr 5, 2023

🤖 Effect of this PR on checked open source code: 🤖

Effect on black:
The following messages are no longer emitted:

  1. unused-argument:
    Unused argument 'args'
    https://github.com/psf/black/blob/a552f7096a9f6e016c9bb1df1e0a77a17caeec1c/src/blib2to3/pytree.py#L79
  2. unused-argument:
    Unused argument 'kwds'
    https://github.com/psf/black/blob/a552f7096a9f6e016c9bb1df1e0a77a17caeec1c/src/blib2to3/pytree.py#L79
  3. unused-argument:
    Unused argument 'args'
    https://github.com/psf/black/blob/a552f7096a9f6e016c9bb1df1e0a77a17caeec1c/src/blib2to3/pytree.py#L531
  4. unused-argument:
    Unused argument 'kwds'
    https://github.com/psf/black/blob/a552f7096a9f6e016c9bb1df1e0a77a17caeec1c/src/blib2to3/pytree.py#L531

Effect on django:
The following messages are now emitted:

  1. redefined-variable-type:
    Redefinition of field type from django.db.models.fields.related.OneToOneField to django.forms.widgets.Widget
    https://github.com/django/django/blob/073b5fd40035759afaebe5c77de5269aee851643/django/db/models/base.py#L346

The following messages are no longer emitted:

  1. unused-argument:
    Unused argument 'setting_name'
    https://github.com/django/django/blob/073b5fd40035759afaebe5c77de5269aee851643/django/conf/__init__.py#L41

Effect on music21:
The following messages are now emitted:

  1. too-many-instance-attributes:
    Too many instance attributes (33/20)
    https://github.com/cuthbertLab/music21/blob/f05ec0af047977eaa8a2c09f7cf99892a5983eb7/music21/roman.py#L1394
  2. redefined-variable-type:
    Redefinition of fundamental type from django.forms.widgets.Widget to music21.pitch.Pitch
    https://github.com/cuthbertLab/music21/blob/f05ec0af047977eaa8a2c09f7cf99892a5983eb7/music21/pitch.py#L3690
  3. invalid-name:
    Attribute name "id" doesn't conform to '[a-z_][A-Za-z0-9_]{2,30}$' pattern
    https://github.com/cuthbertLab/music21/blob/f05ec0af047977eaa8a2c09f7cf99892a5983eb7/music21/prebase.py#L293
  4. useless-suppression:
    Useless suppression of 'attribute-defined-outside-init'
    https://github.com/cuthbertLab/music21/blob/f05ec0af047977eaa8a2c09f7cf99892a5983eb7/music21/base.py#L3193
  5. useless-suppression:
    Useless suppression of 'attribute-defined-outside-init'
    https://github.com/cuthbertLab/music21/blob/f05ec0af047977eaa8a2c09f7cf99892a5983eb7/music21/base.py#L3264
  6. redefined-variable-type:
    Redefinition of pitch2.accidental type from int to float
    https://github.com/cuthbertLab/music21/blob/f05ec0af047977eaa8a2c09f7cf99892a5983eb7/music21/interval.py#L3525
  7. redefined-variable-type:
    Redefinition of mdObj type from django.forms.widgets.Widget to music21.metadata.Metadata
    https://github.com/cuthbertLab/music21/blob/f05ec0af047977eaa8a2c09f7cf99892a5983eb7/music21/musicxml/m21ToXml.py#L2581
  8. redefined-variable-type:
    Redefinition of self.previousRn type from django.forms.widgets.Widget to music21.note.Rest
    https://github.com/cuthbertLab/music21/blob/f05ec0af047977eaa8a2c09f7cf99892a5983eb7/music21/romanText/translate.py#L795
  9. redefined-variable-type:
    Redefinition of self.previousChordInMeasure type from django.forms.widgets.Widget to music21.note.Rest
    https://github.com/cuthbertLab/music21/blob/f05ec0af047977eaa8a2c09f7cf99892a5983eb7/music21/romanText/translate.py#L794
  10. redefined-variable-type:
    Redefinition of lastChord type from music21.chord.Chord to django.forms.widgets.Widget
    https://github.com/cuthbertLab/music21/blob/f05ec0af047977eaa8a2c09f7cf99892a5983eb7/music21/analysis/neoRiemannian.py#L435
  11. useless-suppression:
    Useless suppression of 'method-hidden'
    https://github.com/cuthbertLab/music21/blob/f05ec0af047977eaa8a2c09f7cf99892a5983eb7/music21/stream/base.py#L11551
  12. redefined-variable-type:
    Redefinition of theRest type from music21.note.Rest to list
    https://github.com/cuthbertLab/music21/blob/f05ec0af047977eaa8a2c09f7cf99892a5983eb7/music21/mei/base.py#L2310
  13. redefined-variable-type:
    Redefinition of theSpace type from music21.note.Rest to list
    https://github.com/cuthbertLab/music21/blob/f05ec0af047977eaa8a2c09f7cf99892a5983eb7/music21/mei/base.py#L2358

The following messages are no longer emitted:

  1. too-many-instance-attributes:
    Too many instance attributes (34/20)
    https://github.com/cuthbertLab/music21/blob/f05ec0af047977eaa8a2c09f7cf99892a5983eb7/music21/roman.py#L1394
  2. invalid-name:
    Attribute name "id" doesn't conform to '[a-z_][A-Za-z0-9_]{2,30}$' pattern
    https://github.com/cuthbertLab/music21/blob/f05ec0af047977eaa8a2c09f7cf99892a5983eb7/music21/base.py#L576
  3. suppressed-message:
    Suppressed 'attribute-defined-outside-init' (from line 3193)
    https://github.com/cuthbertLab/music21/blob/f05ec0af047977eaa8a2c09f7cf99892a5983eb7/music21/base.py#L3193
  4. suppressed-message:
    Suppressed 'attribute-defined-outside-init' (from line 3264)
    https://github.com/cuthbertLab/music21/blob/f05ec0af047977eaa8a2c09f7cf99892a5983eb7/music21/base.py#L3264
  5. redefined-variable-type:
    Redefinition of keySignatures type from list to music21.stream.iterator.StreamIterator
    https://github.com/cuthbertLab/music21/blob/f05ec0af047977eaa8a2c09f7cf99892a5983eb7/music21/stream/base.py#L3261
  6. redefined-variable-type:
    Redefinition of ksIter type from list to music21.stream.iterator.StreamIterator
    https://github.com/cuthbertLab/music21/blob/f05ec0af047977eaa8a2c09f7cf99892a5983eb7/music21/stream/base.py#L6782
  7. suppressed-message:
    Suppressed 'method-hidden' (from line 11551)
    https://github.com/cuthbertLab/music21/blob/f05ec0af047977eaa8a2c09f7cf99892a5983eb7/music21/stream/base.py#L11552
  8. redefined-variable-type:
    Redefinition of self.activeInstrument type from music21.instrument.UnpitchedPercussion to music21.instrument.Instrument
    https://github.com/cuthbertLab/music21/blob/f05ec0af047977eaa8a2c09f7cf99892a5983eb7/music21/musicxml/xmlToM21.py#L2121

Effect on pandas:
The following messages are now emitted:

  1. invalid-name:
    Attribute name "y" doesn't conform to snake_case naming style
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/reshape/test_pivot.py#L1791
  2. redefined-variable-type:
    Redefinition of data type from pandas.core.internals.array_manager.SingleArrayManager to pandas.core.internals.managers.SingleBlockManager
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/core/series.py#L416
  3. using-constant-test:
    Using a conditional statement with a constant value
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/core/generic.py#L6141
  4. redefined-variable-type:
    Redefinition of indexer type from .ndarray to slice
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/core/indexes/multi.py#L3077
  5. no-member:
    Instance of 'Index' has no 'levels' member; maybe 'nlevels'?
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/core/indexes/base.py#L2067
  6. no-member:
    Instance of 'Index' has no 'codes' member
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/core/indexes/base.py#L2068
  7. redefined-variable-type:
    Redefinition of arr type from pandas.core.arrays.string_.StringArray to pandas.core.arrays.integer.IntegerArray
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/core/internals/construction.py#L1033
  8. redefined-variable-type:
    Redefinition of expected type from pandas.core.indexes.timedeltas.TimedeltaIndex to pandas.core.indexes.base.Index
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/arithmetic/test_numeric.py#L206
  9. redefined-variable-type:
    Redefinition of expected type from pandas.core.indexes.timedeltas.TimedeltaIndex to pandas.core.indexes.base.Index
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/arithmetic/test_numeric.py#L262
  10. redefined-variable-type:
    Redefinition of expected type from pandas.core.indexes.datetimes.DatetimeIndex to pandas.core.arrays.period.PeriodArray
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/arithmetic/test_datetime64.py#L1574
  11. redefined-variable-type:
    Redefinition of expected type from .ndarray to pandas.core.indexes.period.PeriodIndex
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/indexes/period/test_period_range.py#L77
  12. redefined-variable-type:
    Redefinition of result type from pandas.core.indexes.interval.IntervalIndex to pandas.core.indexes.base.Index
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/indexes/interval/test_interval.py#L385
  13. redefined-variable-type:
    Redefinition of dti type from pandas.core.indexes.datetimes.DatetimeIndex to pandas.core.indexes.datetimelike.DatetimeTimedeltaMixin
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/indexes/datetimes/methods/test_snap.py#L28
  14. redefined-variable-type:
    Redefinition of expected type from pandas.core.frame.DataFrame to pandas.core.series.Series
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/groupby/test_filters.py#L376
  15. redefined-variable-type:
    Redefinition of expected type from pandas.core.frame.DataFrame to pandas.core.series.Series
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/groupby/test_filters.py#L418
  16. redefined-variable-type:
    Redefinition of expected type from pandas.core.frame.DataFrame to pandas.core.series.Series
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/groupby/test_filters.py#L460
  17. redefined-variable-type:
    Redefinition of expected type from pandas.core.frame.DataFrame to pandas.core.series.Series
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/groupby/test_filters.py#L505
  18. redefined-variable-type:
    Redefinition of expected type from pandas.core.frame.DataFrame to pandas.core.series.Series
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/groupby/test_filters.py#L547
  19. redefined-variable-type:
    Redefinition of expected type from tuple to pandas.core.series.Series
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/series/methods/test_astype.py#L514
  20. no-member:
    Instance of 'SingleBlockManager' has no 'iget' member
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/internals/test_internals.py#L555
  21. no-member:
    Instance of 'SingleBlockManager' has no 'iget' member
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/internals/test_internals.py#L556
  22. no-member:
    Instance of 'SingleBlockManager' has no 'iget' member
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/internals/test_internals.py#L557
  23. no-member:
    Instance of 'SingleBlockManager' has no 'iget' member
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/internals/test_internals.py#L564
  24. no-member:
    Instance of 'SingleBlockManager' has no 'iget' member
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/internals/test_internals.py#L565
  25. no-member:
    Instance of 'SingleBlockManager' has no 'iget' member
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/internals/test_internals.py#L566
  26. no-member:
    Instance of 'SingleBlockManager' has no 'iget' member
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/internals/test_internals.py#L567
  27. no-member:
    Instance of 'SingleBlockManager' has no 'iget' member
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/internals/test_internals.py#L569
  28. no-member:
    Instance of 'SingleBlockManager' has no 'iget' member
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/internals/test_internals.py#L570
  29. no-member:
    Instance of 'SingleBlockManager' has no 'iget' member
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/internals/test_internals.py#L572
  30. no-member:
    Instance of 'SingleBlockManager' has no 'iget' member
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/internals/test_internals.py#L574
  31. no-member:
    Instance of 'SingleBlockManager' has no 'iget' member
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/internals/test_internals.py#L611
  32. no-member:
    Instance of 'SingleBlockManager' has no 'iget' member
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/internals/test_internals.py#L612
  33. no-member:
    Instance of 'SingleBlockManager' has no 'iget' member
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/internals/test_internals.py#L613
  34. no-member:
    Instance of 'SingleBlockManager' has no 'iget' member
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/internals/test_internals.py#L614
  35. no-member:
    Instance of 'SingleBlockManager' has no 'iget' member
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/internals/test_internals.py#L615
  36. no-member:
    Instance of 'SingleBlockManager' has no 'iget' member
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/internals/test_internals.py#L624
  37. no-member:
    Instance of 'SingleBlockManager' has no 'iget' member
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/internals/test_internals.py#L625
  38. no-member:
    Instance of 'SingleBlockManager' has no 'iget' member
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/internals/test_internals.py#L626
  39. no-member:
    Instance of 'SingleBlockManager' has no 'iget' member
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/internals/test_internals.py#L627
  40. no-member:
    Instance of 'SingleBlockManager' has no 'iget' member
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/internals/test_internals.py#L628
  41. no-member:
    Instance of 'SingleBlockManager' has no 'iget' member
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/internals/test_internals.py#L629
  42. no-member:
    Instance of 'SingleBlockManager' has no 'iget' member
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/internals/test_internals.py#L630
  43. no-member:
    Instance of 'SingleBlockManager' has no 'iget' member
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/internals/test_internals.py#L631
  44. no-member:
    Instance of 'SingleBlockManager' has no 'iget' member
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/internals/test_internals.py#L632

The following messages are no longer emitted:

  1. unused-argument:
    Unused argument 'date_format'
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/io/excel/_base.py#L1098
  2. unused-argument:
    Unused argument 'datetime_format'
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/io/excel/_base.py#L1099
  3. unused-argument:
    Unused argument 'mode'
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/io/excel/_base.py#L1100
  4. unused-argument:
    Unused argument 'storage_options'
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/io/excel/_base.py#L1101
  5. unused-argument:
    Unused argument 'if_sheet_exists'
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/io/excel/_base.py#L1102
  6. unused-argument:
    Unused argument 'engine_kwargs'
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/io/excel/_base.py#L1103
  7. redefined-variable-type:
    Redefinition of result type from tuple to .ndarray
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/test_algos.py#L586
  8. redefined-variable-type:
    Redefinition of result type from tuple to pandas.core.indexes.base.Index
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/test_algos.py#L719
  9. no-member:
    Instance of 'DatetimeIndex' has no 'month' member
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/resample/test_datetime_index.py#L1120
  10. no-member:
    Instance of 'DatetimeIndex' has no 'month' member
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/resample/test_datetime_index.py#L1139
  11. redefined-variable-type:
    Redefinition of times type from pandas.core.indexes.datetimes.DatetimeIndex to pandas.core.frame.DataFrame
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/tools/test_to_datetime.py#L3476
  12. redefined-variable-type:
    Redefinition of result type from pandas.core.indexes.datetimes.DatetimeIndex to pandas.core.indexes.base.Index
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/indexes/test_base.py#L243
  13. redefined-variable-type:
    Redefinition of index type from pandas.core.indexes.timedeltas.TimedeltaIndex to pandas.core.indexes.datetimes.DatetimeIndex
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/indexes/test_base.py#L274
  14. redefined-variable-type:
    Redefinition of tdi type from pandas.core.indexes.timedeltas.TimedeltaIndex to pandas.core.indexes.datetimes.DatetimeIndex
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/indexes/timedeltas/test_pickle.py#L8
  15. redefined-variable-type:
    Redefinition of res type from pandas.core.indexes.base.Index to pandas.core.series.Series
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/indexes/timedeltas/test_timedelta.py#L121
  16. redefined-variable-type:
    Redefinition of result type from pandas.core.indexes.base.Index to pandas.core.series.Series
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/indexes/object/test_astype.py#L22
  17. redefined-variable-type:
    Redefinition of dr type from pandas.core.indexes.datetimes.DatetimeIndex to pandas.core.indexes.base.Index
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/indexes/datetimes/test_timezones.py#L597
  18. redefined-variable-type:
    Redefinition of result type from pandas.core.indexes.datetimes.DatetimeIndex to pandas.core.indexes.base.Index
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/indexes/datetimes/methods/test_shift.py#L63
  19. redefined-variable-type:
    Redefinition of result type from pandas.core.indexes.interval.IntervalIndex to pandas.core.indexes.base.Index
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/indexes/interval/test_interval.py#L380
  20. redefined-variable-type:
    Redefinition of expected type from pandas.core.indexes.interval.IntervalIndex to pandas.core.indexes.base.Index
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/indexes/interval/test_interval.py#L722
  21. redefined-variable-type:
    Redefinition of expected type from pandas.core.indexes.period.PeriodIndex to .ndarray
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/indexes/period/test_period_range.py#L73
  22. redefined-variable-type:
    Redefinition of expected type from pandas.core.series.Series to pandas.core.frame.DataFrame
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/extension/base/constructors.py#L100
  23. redefined-variable-type:
    Redefinition of other type from pandas.core.indexes.base.Index to pandas.core.indexes.datetimes.DatetimeIndex
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/arithmetic/test_datetime64.py#L786
  24. redefined-variable-type:
    Redefinition of expected type from pandas.core.indexes.datetimes.DatetimeIndex to pandas.core.indexes.base.Index
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/arithmetic/test_datetime64.py#L1564
  25. redefined-variable-type:
    Redefinition of expected type from pandas.core.indexes.datetimes.DatetimeIndex to pandas.core.indexes.base.Index
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/arithmetic/test_datetime64.py#L2369
  26. redefined-variable-type:
    Redefinition of expected type from pandas.core.indexes.datetimes.DatetimeIndex to pandas.core.indexes.base.Index
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/arithmetic/test_datetime64.py#L2384
  27. redefined-variable-type:
    Redefinition of expected type from pandas.core.indexes.timedeltas.TimedeltaIndex to pandas.core.indexes.base.Index
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/arithmetic/test_timedelta64.py#L1332
  28. redefined-variable-type:
    Redefinition of expected_sub type from pandas.core.indexes.timedeltas.TimedeltaIndex to pandas.core.indexes.base.Index
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/arithmetic/test_timedelta64.py#L1342
  29. redefined-variable-type:
    Redefinition of left type from pandas.core.indexes.period.PeriodIndex to pandas.core.indexes.base.Index
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/arithmetic/test_period.py#L379
  30. redefined-variable-type:
    Redefinition of right type from pandas.core.indexes.period.PeriodIndex to pandas.core.indexes.base.Index
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/arithmetic/test_period.py#L380
  31. redefined-variable-type:
    Redefinition of expected type from pandas.core.indexes.period.PeriodIndex to pandas.core.indexes.base.Index
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/arithmetic/test_period.py#L874
  32. redefined-variable-type:
    Redefinition of expected type from pandas.core.indexes.timedeltas.TimedeltaIndex to pandas.core.indexes.base.Index
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/arithmetic/test_numeric.py#L204
  33. redefined-variable-type:
    Redefinition of expected type from pandas.core.indexes.timedeltas.TimedeltaIndex to pandas.core.indexes.base.Index
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/arithmetic/test_numeric.py#L260
  34. redefined-variable-type:
    Redefinition of expected type from pandas.core.frame.DataFrame to pandas.core.series.Series
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/groupby/test_filters.py#L372
  35. redefined-variable-type:
    Redefinition of expected type from pandas.core.frame.DataFrame to pandas.core.series.Series
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/groupby/test_filters.py#L414
  36. redefined-variable-type:
    Redefinition of expected type from pandas.core.frame.DataFrame to pandas.core.series.Series
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/groupby/test_filters.py#L456
  37. redefined-variable-type:
    Redefinition of expected type from pandas.core.frame.DataFrame to pandas.core.series.Series
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/groupby/test_filters.py#L501
  38. redefined-variable-type:
    Redefinition of expected type from pandas.core.frame.DataFrame to pandas.core.series.Series
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/groupby/test_filters.py#L543
  39. redefined-variable-type:
    Redefinition of idx type from pandas.core.indexes.timedeltas.TimedeltaIndex to pandas.core.indexes.datetimes.DatetimeIndex
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/arrays/categorical/test_constructors.py#L371
  40. redefined-variable-type:
    Redefinition of df type from pandas.core.series.Series to pandas.core.frame.DataFrame
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/generic/test_duplicate_labels.py#L78
  41. redefined-variable-type:
    Redefinition of a type from pandas.core.series.Series to pandas.core.frame.DataFrame
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/generic/test_duplicate_labels.py#L409
  42. no-member:
    Instance of 'DatetimeIndex' has no 'normalize' member
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/frame/methods/test_asfreq.py#L210
  43. redefined-variable-type:
    Redefinition of obj type from pandas.core.series.Series to pandas.core.frame.DataFrame
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/frame/methods/test_truncate.py#L146
  44. redefined-variable-type:
    Redefinition of idx1 type from pandas.core.indexes.period.PeriodIndex to pandas.core.indexes.base.Index
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/frame/methods/test_set_index.py#L489
  45. redefined-variable-type:
    Redefinition of idx type from pandas.core.indexes.period.PeriodIndex to pandas.core.indexes.base.Index
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/frame/indexing/test_where.py#L876
  46. redefined-variable-type:
    Redefinition of idx type from pandas.core.indexes.datetimes.DatetimeIndex to pandas.core.indexes.period.PeriodIndex
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/indexing/test_loc.py#L2672
  47. redefined-variable-type:
    Redefinition of data type from pandas.core.internals.array_manager.SingleArrayManager to pandas.core.internals.managers.BlockManager
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/core/series.py#L416
  48. invalid-name:
    Attribute name "y" doesn't conform to snake_case naming style
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/tests/generic/test_frame.py#L140
  49. unsupported-assignment-operation:
    'mangled_aggspec' does not support item assignment
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/core/apply.py#L1479
  50. redefined-variable-type:
    Redefinition of mangled_aggspec type from str to list
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/core/apply.py#L1481
  51. unused-argument:
    Unused argument 'env'
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/core/computation/ops.py#L71
  52. unused-argument:
    Unused argument 'side'
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/core/computation/ops.py#L71
  53. unused-argument:
    Unused argument 'encoding'
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/core/computation/ops.py#L71
  54. redefined-variable-type:
    Redefinition of values type from .ndarray to pandas.core.arrays.arrow.array.ArrowExtensionArray
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/core/tools/numeric.py#L303
  55. unused-argument:
    Unused argument 'normalize'
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/core/indexes/datetimes.py#L313
  56. unused-argument:
    Unused argument 'closed'
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/core/indexes/datetimes.py#L314
  57. no-member:
    Instance of 'RangeIndex' has no 'levels' member; maybe 'nlevels'?
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/core/indexes/base.py#L2067
  58. no-member:
    Instance of 'RangeIndex' has no 'codes' member
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/core/indexes/base.py#L2068
  59. unused-argument:
    Unused argument 'closed'
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/core/indexes/timedeltas.py#L135
  60. unused-argument:
    Unused argument 'args'
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/core/groupby/grouper.py#L251
  61. redefined-variable-type:
    Redefinition of item type from pandas.core.arrays.period.PeriodArray to slice
    https://github.com/pandas-dev/pandas/blob/5a1f280647bca201ddc7168b2b01e65d89419ca7/pandas/core/arrays/arrow/array.py#L379

This comment was generated for commit 3411d52

@Emplis Emplis force-pushed the fix-check-unused-args branch from 64a5d0a to f9ef291 Compare April 5, 2023 15:58
@Pierre-Sassoulas Pierre-Sassoulas added False Positive 🦟 A message is emitted but nothing is wrong with the code backport maintenance/3.3.x labels Apr 5, 2023
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.17.3 milestone Apr 5, 2023
Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this, the primer results look pretty good ! Could you also add a functional tests, please ?

@Emplis Emplis force-pushed the fix-check-unused-args branch from f9ef291 to 3dec21f Compare April 6, 2023 09:02
@Emplis
Copy link
Contributor Author

Emplis commented Apr 6, 2023

Rebased to fix failing primer tests and added a test as requested.

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you ! Could you also add a fragment for the changelog, please ?

@Emplis Emplis force-pushed the fix-check-unused-args branch from a82ed13 to 0418188 Compare April 6, 2023 10:33
@Emplis
Copy link
Contributor Author

Emplis commented Apr 6, 2023

Rebased to include the changelog fragment into the first commit.

Emplis added 2 commits April 6, 2023 12:37
Problem: the special method `__new__` must match the arguments of the
`__init__` method even if `__new__` method does not use them. This
generate `unused-argument` for the `__new__` method.

Fix: the unused arguments check should not be done on the `__new__`
method if the `__init__` method is defined in the same class.

Fixes pylint-dev#3670
Update `unused-argument` test to include a check for the case of
`__init__` and `__new__` being defined in a class but `__new__` does not
use all of the argument. This is fine because `__new__` must have the
same argument of `__init__`.

Update with a second check in case of `__init__` being not defined in a
class. Then the unused arguments check must be done on `__new__`.
@Emplis Emplis force-pushed the fix-check-unused-args branch from 3417c49 to 66ee6a6 Compare April 6, 2023 10:38
Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great first contribution !

@Pierre-Sassoulas Pierre-Sassoulas merged commit 156da64 into pylint-dev:main Apr 6, 2023
github-actions bot pushed a commit that referenced this pull request Apr 6, 2023
Problem: the special method `__new__` must match the arguments of the
`__init__` method even if `__new__` method does not use them. This
generate `unused-argument` for the `__new__` method.

Fix: the unused arguments check should not be done on the `__new__`
method if the `__init__` method is defined in the same class.

Update `unused-argument` test to include a check for the case of
`__init__` and `__new__` being defined in a class but `__new__` does not
use all of the argument. This is fine because `__new__` must have the
same argument of `__init__`.

Update with a second check in case of `__init__` being not defined in a
class. Then the unused arguments check must be done on `__new__`.

Fixes #3670

(cherry picked from commit 156da64)
Pierre-Sassoulas pushed a commit that referenced this pull request Apr 6, 2023
Problem: the special method `__new__` must match the arguments of the
`__init__` method even if `__new__` method does not use them. This
generate `unused-argument` for the `__new__` method.

Fix: the unused arguments check should not be done on the `__new__`
method if the `__init__` method is defined in the same class.

Update `unused-argument` test to include a check for the case of
`__init__` and `__new__` being defined in a class but `__new__` does not
use all of the argument. This is fine because `__new__` must have the
same argument of `__init__`.

Update with a second check in case of `__init__` being not defined in a
class. Then the unused arguments check must be done on `__new__`.

Fixes #3670

(cherry picked from commit 156da64)

Co-authored-by: Théo Battrel <theo.util@protonmail.ch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backported False Positive 🦟 A message is emitted but nothing is wrong with the code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unused-argument for required argument in __new__
2 participants