Skip to content
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

Lib/ be more pythonic #77010

Closed
dilyanpalauzov mannequin opened this issue Feb 12, 2018 · 5 comments
Closed

Lib/ be more pythonic #77010

dilyanpalauzov mannequin opened this issue Feb 12, 2018 · 5 comments
Labels
3.8 only security fixes build The build process and cross-build performance Performance or resource usage

Comments

@dilyanpalauzov
Copy link
Mannequin

dilyanpalauzov mannequin commented Feb 12, 2018

BPO 32829
Nosy @terryjreedy, @tiran, @bitdancer

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2018-03-17.18:07:58.553>
created_at = <Date 2018-02-12.12:06:40.005>
labels = ['build', '3.8', 'performance']
title = 'Lib/ be more pythonic'
updated_at = <Date 2018-03-17.18:07:58.546>
user = 'https://bugs.python.org/dilyanpalauzov'

bugs.python.org fields:

activity = <Date 2018-03-17.18:07:58.546>
actor = 'r.david.murray'
assignee = 'none'
closed = True
closed_date = <Date 2018-03-17.18:07:58.553>
closer = 'r.david.murray'
components = ['Build']
creation = <Date 2018-02-12.12:06:40.005>
creator = 'dilyan.palauzov'
dependencies = []
files = []
hgrepos = []
issue_num = 32829
keywords = []
message_count = 5.0
messages = ['312040', '312041', '312253', '313270', '314009']
nosy_count = 4.0
nosy_names = ['terry.reedy', 'christian.heimes', 'r.david.murray', 'dilyan.palauzov']
pr_nums = []
priority = 'normal'
resolution = 'rejected'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'performance'
url = 'https://bugs.python.org/issue32829'
versions = ['Python 3.8']

@dilyanpalauzov
Copy link
Mannequin Author

dilyanpalauzov mannequin commented Feb 12, 2018

diff --git a/Lib/distutils/command/sdist.py b/Lib/distutils/command/sdist.py
--- a/Lib/distutils/command/sdist.py
+++ b/Lib/distutils/command/sdist.py
@@ -251,14 +251,11 @@ class sdist(Command):
         for fn in standards:
             if isinstance(fn, tuple):
                 alts = fn
-                got_it = False
                 for fn in alts:
                     if self._cs_path_exists(fn):
-                        got_it = True
                         self.filelist.append(fn)
                         break
-
-                if not got_it:
+                else:
                     self.warn("standard file not found: should have one of " +
                               ', '.join(alts))
             else:
diff --git a/Lib/email/_header_value_parser.py b/Lib/email/_header_value_parser.py
--- a/Lib/email/_header_value_parser.py
+++ b/Lib/email/_header_value_parser.py
@@ -567,14 +567,7 @@ class DisplayName(Phrase):
 
     @property
     def value(self):
-        quote = False
-        if self.defects:
-            quote = True
-        else:
-            for x in self:
-                if x.token_type == 'quoted-string':
-                    quote = True
-        if quote:
+        if self.defects or any(x.token_type == 'quoted-string' for x in self):
             pre = post = ''
             if self[0].token_type=='cfws' or self[0][0].token_type=='cfws':
                 pre = ' '
diff --git a/Lib/idlelib/config.py b/Lib/idlelib/config.py
--- a/Lib/idlelib/config.py
+++ b/Lib/idlelib/config.py
@@ -402,7 +402,7 @@ class IdleConf:
         because setting 'name' to a builtin not defined in older IDLEs
         to display multiple error messages or quit.
         See https://bugs.python.org/issue25313.
-        When default = True, 'name2' takes precedence over 'name',
+        When default is True, 'name2' takes precedence over 'name',
         while older IDLEs will just use name.  When default = False,
         'name2' may still be set, but it is ignored.
         """

@dilyanpalauzov dilyanpalauzov mannequin added 3.8 only security fixes build The build process and cross-build performance Performance or resource usage labels Feb 12, 2018
@tiran
Copy link
Member

tiran commented Feb 12, 2018

We generally don't accept patches on bugs.python.org. Please open a pull request on github, see https://devguide.python.org/#contributing

@terryjreedy
Copy link
Member

Dilyan, please explain what you believe the problems to be and how the patch solves it. These seem to be 3 separate issues.

Do not change idlelib.config. config_main.def contain 'default = True' or 'default = False' and that is what the docstring references.

@dilyanpalauzov
Copy link
Mannequin Author

dilyanpalauzov mannequin commented Mar 5, 2018

The variables got_it in distutils/command/sdist and quote in email/_header_value_parser can be skipped making the code shorter and faster.

@bitdancer
Copy link
Member

The risk of introducing a bug is higher than the minimal benefit of making the changes. Thus we do not typically accept changes like this. We'll clean up such code when we touching it for other reasons.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.8 only security fixes build The build process and cross-build performance Performance or resource usage
Projects
None yet
Development

No branches or pull requests

3 participants