mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	docs: Update Python guidance in code style.
This commit is contained in:
		@@ -131,13 +131,12 @@ rules about integrating third-party projects.
 | 
				
			|||||||
  tool](../testing/linters.md) enforces this by running Black and
 | 
					  tool](../testing/linters.md) enforces this by running Black and
 | 
				
			||||||
  isort in check mode, or in write mode with
 | 
					  isort in check mode, or in write mode with
 | 
				
			||||||
  `tools/lint --only=black,isort --fix`. You may find it helpful to
 | 
					  `tools/lint --only=black,isort --fix`. You may find it helpful to
 | 
				
			||||||
  [integrate
 | 
					  [integrate Black](https://black.readthedocs.io/en/stable/integrations/editors.html)
 | 
				
			||||||
  Black](https://black.readthedocs.io/en/stable/integrations/editors.html)
 | 
					 | 
				
			||||||
  and
 | 
					  and
 | 
				
			||||||
  [isort](https://pycqa.github.io/isort/#installing-isorts-for-your-preferred-text-editor)
 | 
					  [isort](https://pycqa.github.io/isort/#installing-isorts-for-your-preferred-text-editor)
 | 
				
			||||||
  with your editor.
 | 
					  with your editor.
 | 
				
			||||||
- Don't put a shebang line on a Python file unless it's meaningful to
 | 
					- Don't put a shebang line on a Python file unless it's meaningful to
 | 
				
			||||||
  run it as a script. (Some libraries can also be run as scripts, e.g.
 | 
					  run it as a script. (Some libraries can also be run as scripts, e.g.,
 | 
				
			||||||
  to run a test suite.)
 | 
					  to run a test suite.)
 | 
				
			||||||
- Scripts should be executed directly (`./script.py`), so that the
 | 
					- Scripts should be executed directly (`./script.py`), so that the
 | 
				
			||||||
  interpreter is implicitly found from the shebang line, rather than
 | 
					  interpreter is implicitly found from the shebang line, rather than
 | 
				
			||||||
@@ -145,12 +144,10 @@ rules about integrating third-party projects.
 | 
				
			|||||||
- Put all imports together at the top of the file, absent a compelling
 | 
					- Put all imports together at the top of the file, absent a compelling
 | 
				
			||||||
  reason to do otherwise.
 | 
					  reason to do otherwise.
 | 
				
			||||||
- Unpacking sequences doesn't require list brackets:
 | 
					- Unpacking sequences doesn't require list brackets:
 | 
				
			||||||
 | 
					 | 
				
			||||||
  ```python
 | 
					  ```python
 | 
				
			||||||
  [x, y] = xs    # unnecessary
 | 
					  [x, y] = xs    # unnecessary
 | 
				
			||||||
  x, y = xs      # better
 | 
					  x, y = xs      # better
 | 
				
			||||||
  ```
 | 
					  ```
 | 
				
			||||||
 | 
					 | 
				
			||||||
- For string formatting, use `x % (y,)` rather than `x % y`, to avoid
 | 
					- For string formatting, use `x % (y,)` rather than `x % y`, to avoid
 | 
				
			||||||
  ambiguity if `y` happens to be a tuple.
 | 
					  ambiguity if `y` happens to be a tuple.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user