@ -15,10 +15,14 @@
 
		
	
		
			
				# along with this program.  If not, see <http://www.gnu.org/licenses/>.  
		
	
		
			
				
 
		
	
		
			
				"""  
		
	
		
			
				Use  this  rule  to  control  the  number  of  spaces  inside  braces  ( ` ` { ` `  and  ` ` } ` ` ) .  
		
	
		
			
				Use  this  rule  to  control  the  use  of  flow  mappings  or  number  of  spaces  inside  
		
	
		
			
				braces  ( ` ` { ` `  and  ` ` } ` ` ) .  
		
	
		
			
				
 
		
	
		
			
				. .  rubric : :  Options  
		
	
		
			
				
 
		
	
		
			
				*  ` ` forbid ` `  is  used  to  forbid  the  use  of  flow  mappings  which  are  denoted  by  
		
	
		
			
				  surrounding  braces  ( ` ` { ` `  and  ` ` } ` ` ) .  Use  ` ` true ` `  to  forbid  the  use  of  flow 
 
		
	
		
			
				  mappings  completely . 
 
		
	
		
			
				*  ` ` min - spaces - inside ` `  defines  the  minimal  number  of  spaces  required  inside  
		
	
		
			
				  braces . 
 
		
	
		
			
				*  ` ` max - spaces - inside ` `  defines  the  maximal  number  of  spaces  allowed  inside  
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -34,6 +38,7 @@ Use this rule to control the number of spaces inside braces (``{`` and ``}``).
 
		
	
		
			
				
 
		
	
		
			
				 rules : 
 
		
	
		
			
				   braces : 
 
		
	
		
			
				     forbid :  false 
 
		
	
		
			
				     min - spaces - inside :  0 
 
		
	
		
			
				     max - spaces - inside :  0 
 
		
	
		
			
				     min - spaces - inside - empty :  - 1 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -41,6 +46,20 @@ Use this rule to control the number of spaces inside braces (``{`` and ``}``).
 
		
	
		
			
				
 
		
	
		
			
				. .  rubric : :  Examples  
		
	
		
			
				
 
		
	
		
			
				#. With ``braces: {forbid: true}``  
		
	
		
			
				
 
		
	
		
			
				   the  following  code  snippet  would  * * PASS * * : 
 
		
	
		
			
				   : : 
 
		
	
		
			
				
 
		
	
		
			
				    object : 
 
		
	
		
			
				      key1 :  4 
 
		
	
		
			
				      key2 :  8 
 
		
	
		
			
				
 
		
	
		
			
				   the  following  code  snippet  would  * * FAIL * * : 
 
		
	
		
			
				   : : 
 
		
	
		
			
				
 
		
	
		
			
				    object :  {  key1 :  4 ,  key2 :  8  } 
 
		
	
		
			
				
 
		
	
		
			
				#. With ``braces: {min-spaces-inside: 0, max-spaces-inside: 0}``  
		
	
		
			
				
 
		
	
		
			
				   the  following  code  snippet  would  * * PASS * * : 
 
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
			
			@ -103,23 +122,31 @@ Use this rule to control the number of spaces inside braces (``{`` and ``}``).
 
		
	
		
			
				
 
		
	
		
			
				import  yaml  
		
	
		
			
				
 
		
	
		
			
				from  yamllint . linter  import  LintProblem  
		
	
		
			
				from  yamllint . rules . common  import  spaces_after ,  spaces_before  
		
	
		
			
				
 
		
	
		
			
				
 
		
	
		
			
				ID  =  ' braces '  
		
	
		
			
				TYPE  =  ' token '  
		
	
		
			
				CONF  =  { ' min-spaces-inside ' :  int ,  
		
	
		
			
				CONF  =  { ' forbid ' :  bool ,  
		
	
		
			
				        ' min-spaces-inside ' :  int , 
 
		
	
		
			
				        ' max-spaces-inside ' :  int , 
 
		
	
		
			
				        ' min-spaces-inside-empty ' :  int , 
 
		
	
		
			
				        ' max-spaces-inside-empty ' :  int } 
 
		
	
		
			
				DEFAULT  =  { ' min-spaces-inside ' :  0 ,  
		
	
		
			
				DEFAULT  =  { ' forbid ' :  False ,  
		
	
		
			
				           ' min-spaces-inside ' :  0 , 
 
		
	
		
			
				           ' max-spaces-inside ' :  0 , 
 
		
	
		
			
				           ' min-spaces-inside-empty ' :  - 1 , 
 
		
	
		
			
				           ' max-spaces-inside-empty ' :  - 1 } 
 
		
	
		
			
				
 
		
	
		
			
				
 
		
	
		
			
				def  check ( conf ,  token ,  prev ,  next ,  nextnext ,  context ) :  
		
	
		
			
				    if  ( isinstance ( token ,  yaml . FlowMappingStartToken )  and 
 
		
	
		
			
				    if  conf [ ' forbid ' ]  and  isinstance ( token ,  yaml . FlowMappingStartToken ) : 
 
		
	
		
			
				        yield  LintProblem ( token . start_mark . line  +  1 , 
 
		
	
		
			
				                          token . end_mark . column  +  1 , 
 
		
	
		
			
				                          ' forbidden flow mapping ' ) 
 
		
	
		
			
				
 
		
	
		
			
				    elif  ( isinstance ( token ,  yaml . FlowMappingStartToken )  and 
 
		
	
		
			
				            isinstance ( next ,  yaml . FlowMappingEndToken ) ) : 
 
		
	
		
			
				        problem  =  spaces_after ( token ,  prev ,  next , 
 
		
	
		
			
				                               min = ( conf [ ' min-spaces-inside-empty ' ]