-
Notifications
You must be signed in to change notification settings - Fork 188
Allowing convenient selection of checked error codes #96
Description
#0 Introduction
In this issue, I'm going to list a number of related features that I feel deserve a clear solution that can't be achieved by solving each one independently. I also suggest a possible solution. *I highly encourage anyone to criticize the features and the solution. Of course everyone is also encouraged to suggest alternative solutions, use cases or related features. In short - show me where I'm wrong.
#1 Features
- Allow the user to pick a "set" of error codes to comply with a certain
standard. For example, choosing between Google style, numpy style and PEP257
(which should be the default behavior). - Allow the user to manually set which error codes are ignored when pep257 is
run (blacklist) - Allow the user to manually set which error codes are considered when pep257
is run (whitelist) - Allow the user to set a docsring convention (as in (1)) and set which
error codes are ignored or selected with respect to the chosen convention. - Allow the user to specify an ignored error code list or convention in a
configuration file and also override it completely with CLI flags. - Allow the user to specify an ignored error code list or conevention in a
configuration file and also add to it with CLI flags.
pep257.py contains PEP-257 errors #2 Status Quo
Right now, the only implemented feature is (2):
pep257 --ignore=D203,D400,D102
#3 Proposed Solution
3.1 Flags
--select=D100,D202
--ignore=D100,D202
--add-ignore=D100,D202
--add-select=D100,D202
--convention=numpy
3.2 Logic
--select
,--ignore
and--convention
are mutually exclusive. It's
illegal to specify more than one of them. However, it is possible to specify
one such flag in the config file and another one (or even the same one) as
a command line flag, in which case the flag specified in the config file
will be completely ignored.- Not specifying either one of the above flags will be treated as if
--convention=pep257
was specified. - The value of the above flags (or the value of the default convention)
determines a list of error codes that should be checked. --add-ignore
and--add-select
can only be specified as command line
flags. Instead of fully determining the list of errors that should be
checked, they alter the list defined by the previously mentioned flags.--add-ignore
and--add-select
are not mutually exclusive. However,
specifying the same error code in both is considered illegal.- Some error codes are mutually exclusive. After determining the final list
of error codes that should be checked, it is considered illegal if two or
more mutually exclusive flags in it.
Handle IOError when file can't be opened #4 Use Cases
For the sake of the following use cases, assume that there exists two mutually
exclusive error codes, D101 and D102. PEP257 uses D101 (so it's on by default)
- D100 - used by all conventions.
- D101 - used by PEP257, but not numpy. Mutually exclusive with D102.
- D102 - used by numpy, but not PEP257. Mutually exclusive with D101.
- D103 - used by PEP257, but not numpy.
- D104 - used by numpy, but not PEP257.
Also assume that there are many more errors of either of these types.
4.1 As the user, I want to use the PEP257 convention
pep257
4.2 As the user, I want to use the PEP257 convention, but also check for D104
pep257 --add-select=D104
4.3 As the user, I want to use the PEP257 convention, but check D102 instead of D101
pep257 --add-ignore=D101 --add-select=D102
4.4 As the user, I don't care about specific conventions. I just want to specifically check for D100 and D102
pep257 --select=D100,D102
4.5 As the user, I want to use the numpy convention, but also check for D103
pep257 --convention=numpy --add-select=D103
4.6 As the user, I want to use the numpy convention, but also ignore D104
pep257 --convention=numpy --add-ignore=D104
4.7 As the user, I want to use the numpy convention, but check D101 instead of D102
The following flags should achieve this:
pep257 --convention=numpy --add-select=D101 --add-ignore=D102
4.8 As the user, I want to usually check for D100, D102 and D104, but sometimes ignore D104 when I run pep257 manually
Config file:
[pep257]
select = D100,D102,D104
Command line:
pep257 --add-ignore=D104
4.9 As the user, I want to usually check for D100, D102 and D104, but sometimes also check for D103 when I run pep257 manually
Config file:
[pep257]
select = D100,D102,D104
Command line:
pep257 --add-select=D103
4.10 As the user, I want to usually check for D100, D102 and D104, but sometimes I want to check by numpy standards instead.
Config file:
[pep257]
select = D100,D102,D104
Command line:
pep257 --convention=numpy